parsePreCandidate.js 1.1 KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports["default"] = parsePreCandidate;
  6. var _util = require("./util.js");
  7. // Regular expression of characters typically used to start a second phone number for the purposes
  8. // of parsing. This allows us to strip off parts of the number that are actually the start of
  9. // another number, such as for: (530) 583-6985 x302/x2303 -> the second extension here makes this
  10. // actually two phone numbers, (530) 583-6985 x302 and (530) 583-6985 x2303. We remove the second
  11. // extension so that the first number is parsed correctly.
  12. //
  13. // Matches a slash (\ or /) followed by a space followed by an `x`.
  14. //
  15. var SECOND_NUMBER_START_PATTERN = /[\\/] *x/;
  16. function parsePreCandidate(candidate) {
  17. // Check for extra numbers at the end.
  18. // TODO: This is the place to start when trying to support extraction of multiple phone number
  19. // from split notations (+41 79 123 45 67 / 68).
  20. return (0, _util.trimAfterFirstMatch)(SECOND_NUMBER_START_PATTERN, candidate);
  21. }
  22. //# sourceMappingURL=parsePreCandidate.js.map