parsePreCandidate.js 979 B

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