libphonenumber-js 1.12.29 → 1.12.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -106
- package/build/PhoneNumberMatcher.js +18 -11
- package/build/PhoneNumberMatcher.js.map +1 -1
- package/build/PhoneNumberMatcher.test.js +15 -0
- package/build/PhoneNumberMatcher.test.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/es6/PhoneNumberMatcher.js +18 -11
- package/es6/PhoneNumberMatcher.js.map +1 -1
- package/es6/PhoneNumberMatcher.test.js +15 -0
- package/es6/PhoneNumberMatcher.test.js.map +1 -1
- package/package.json +1 -1
- package/source/PhoneNumberMatcher.js +12 -8
- package/source/PhoneNumberMatcher.test.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -67,112 +67,117 @@ And edit the README:
|
|
|
67
67
|
|
|
68
68
|
<!-- This changelog [only](https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/16#note_594165443) mentions the changes in the code. See [Google's changelog](https://github.com/google/libphonenumber/blob/master/release_notes.txt) for metadata changes. -->
|
|
69
69
|
|
|
70
|
-
<!-- CHANGELOG START -->
|
|
71
|
-
|
|
72
|
-
1.12.
|
|
73
|
-
===================
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
- Updated
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
- Updated
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
- Updated
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
- Updated
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- Updated
|
|
175
|
-
|
|
70
|
+
<!-- CHANGELOG START -->
|
|
71
|
+
|
|
72
|
+
1.12.30 / 01.12.2025
|
|
73
|
+
===================
|
|
74
|
+
|
|
75
|
+
* Merged [Endy Gower](https://gitlab.com/endycb)'s [fix](https://gitlab.com/catamphetamine/libphonenumber-js/-/merge_requests/27): `findPhoneNumbersInText()` now correctly finds phone numbers that're separated by a `/` character. Example: `651-234-2345/332-445-1234`.
|
|
76
|
+
|
|
77
|
+
1.12.29 / 21.11.2025
|
|
78
|
+
===================
|
|
79
|
+
|
|
80
|
+
* Updated metadata to version 9.0.19:
|
|
81
|
+
- Updated phone metadata for region code(s):
|
|
82
|
+
CF, EE, EH, GE, IN, LB, MA, OM, SG, SN, SV, UG
|
|
83
|
+
- Updated geocoding data for country calling code(s):
|
|
84
|
+
61 (en), 91 (en), 212 (en)
|
|
85
|
+
- Updated carrier data for country calling code(s):
|
|
86
|
+
34 (en), 45 (en), 65 (en), 91 (en), 236 (en), 256 (en), 503 (en), 961 (en),
|
|
87
|
+
995 (en)
|
|
88
|
+
|
|
89
|
+
1.12.26 / 7.11.2025
|
|
90
|
+
===================
|
|
91
|
+
|
|
92
|
+
* Updated metadata to version 9.0.18:
|
|
93
|
+
- Updated phone metadata for region code(s):
|
|
94
|
+
AU, BJ, CC, CX, ET, IL, IR, MC, PY, QA, SG, SV, TJ, UG, ZA
|
|
95
|
+
- Updated short number metadata for region code(s): PY
|
|
96
|
+
- Updated geocoding data for country calling code(s): 61 (en)
|
|
97
|
+
- Updated carrier data for country calling code(s):
|
|
98
|
+
61 (en), 65 (en), 98 (en, fa), 229 (en), 256 (en), 372 (en), 377 (en),
|
|
99
|
+
503 (en), 972 (en), 992 (en)
|
|
100
|
+
- Updated / refreshed time zone meta data.
|
|
101
|
+
|
|
102
|
+
1.12.25 / 24.10.2025
|
|
103
|
+
===================
|
|
104
|
+
|
|
105
|
+
* Updated metadata to version 9.0.17:
|
|
106
|
+
- Updated phone metadata for region code(s): AU, CC, CX, GB, LB, MG, SN
|
|
107
|
+
- Updated short number metadata for region code(s): RO
|
|
108
|
+
- Updated carrier data for country calling code(s):
|
|
109
|
+
57 (en), 61 (en), 221 (en), 255 (en), 261 (en), 852 (zh), 961 (en)
|
|
110
|
+
- Updated / refreshed time zone meta data.
|
|
111
|
+
|
|
112
|
+
1.12.24 / 10.10.2025
|
|
113
|
+
===================
|
|
114
|
+
|
|
115
|
+
* Updated metadata to version 9.0.16:
|
|
116
|
+
- Updated phone metadata for region code(s): CZ, ES, GE, HK, JO, LI, US
|
|
117
|
+
- Updated short number metadata for region code(s): ES
|
|
118
|
+
- New geocoding data for country calling code(s): 1324 (en)
|
|
119
|
+
- Updated geocoding data for country calling code(s): 1437 (en)
|
|
120
|
+
- Updated carrier data for country calling code(s):
|
|
121
|
+
34 (en), 65 (en), 233 (en), 423 (en), 673 (en), 852 (en, zh), 962 (en),
|
|
122
|
+
995 (en)
|
|
123
|
+
- Updated / refreshed time zone meta data.
|
|
124
|
+
|
|
125
|
+
1.12.23 / 26.9.2025
|
|
126
|
+
===================
|
|
127
|
+
|
|
128
|
+
* Updated metadata to version 9.0.15:
|
|
129
|
+
- Updated phone metadata for region code(s): KE, UG, US
|
|
130
|
+
- Updated short number metadata for region code(s): DE, ES
|
|
131
|
+
- Updated carrier data for country calling code(s): 254 (en), 256 (en)
|
|
132
|
+
|
|
133
|
+
1.12.22 / 24.9.2025
|
|
134
|
+
===================
|
|
135
|
+
|
|
136
|
+
* Updated metadata to version 9.0.14:
|
|
137
|
+
- Updated phone metadata for region code(s): CZ, DE, IT, LI, LV, ME, SG, US
|
|
138
|
+
- Updated short number metadata for region code(s): DE
|
|
139
|
+
- New geocoding data for country calling code(s): 1686 (en)
|
|
140
|
+
- Updated geocoding data for country calling code(s): 39 (en, it), 61 (en)
|
|
141
|
+
- Updated carrier data for country calling code(s):
|
|
142
|
+
46 (en), 65 (en), 420 (en), 998 (en)
|
|
143
|
+
- Updated / refreshed time zone meta data.
|
|
144
|
+
|
|
145
|
+
1.12.21 / 23.9.2025
|
|
146
|
+
===================
|
|
147
|
+
|
|
148
|
+
* Updated metadata to version 9.0.14:
|
|
149
|
+
- Updated phone metadata for region code(s): CZ, DE, IT, LI, LV, ME, SG, US
|
|
150
|
+
- Updated short number metadata for region code(s): DE
|
|
151
|
+
- New geocoding data for country calling code(s): 1686 (en)
|
|
152
|
+
- Updated geocoding data for country calling code(s): 39 (en, it), 61 (en)
|
|
153
|
+
- Updated carrier data for country calling code(s):
|
|
154
|
+
46 (en), 65 (en), 420 (en), 998 (en)
|
|
155
|
+
- Updated / refreshed time zone meta data.
|
|
156
|
+
|
|
157
|
+
1.12.20 / 23.9.2025
|
|
158
|
+
===================
|
|
159
|
+
|
|
160
|
+
* Updated metadata to version 9.0.14:
|
|
161
|
+
- Updated phone metadata for region code(s): CZ, DE, IT, LI, LV, ME, SG, US
|
|
162
|
+
- Updated short number metadata for region code(s): DE
|
|
163
|
+
- New geocoding data for country calling code(s): 1686 (en)
|
|
164
|
+
- Updated geocoding data for country calling code(s): 39 (en, it), 61 (en)
|
|
165
|
+
- Updated carrier data for country calling code(s):
|
|
166
|
+
46 (en), 65 (en), 420 (en), 998 (en)
|
|
167
|
+
- Updated / refreshed time zone meta data.
|
|
168
|
+
|
|
169
|
+
1.12.19 / 23.9.2025
|
|
170
|
+
===================
|
|
171
|
+
|
|
172
|
+
* Updated metadata to version 9.0.14:
|
|
173
|
+
- Updated phone metadata for region code(s): CZ, DE, IT, LI, LV, ME, SG, US
|
|
174
|
+
- Updated short number metadata for region code(s): DE
|
|
175
|
+
- New geocoding data for country calling code(s): 1686 (en)
|
|
176
|
+
- Updated geocoding data for country calling code(s): 39 (en, it), 61 (en)
|
|
177
|
+
- Updated carrier data for country calling code(s):
|
|
178
|
+
46 (en), 65 (en), 420 (en), 998 (en)
|
|
179
|
+
- Updated / refreshed time zone meta data.
|
|
180
|
+
|
|
176
181
|
1.12.17 / 12.9.2025
|
|
177
182
|
===================
|
|
178
183
|
|
|
@@ -18,6 +18,9 @@ var _parsePhoneNumber = _interopRequireDefault(require("./parsePhoneNumber.js"))
|
|
|
18
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
20
20
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
21
|
+
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
22
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
23
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
21
24
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
22
25
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
23
26
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -42,7 +45,7 @@ var EXTN_PATTERNS_FOR_MATCHING = (0, _createExtensionPattern["default"])('matchi
|
|
|
42
45
|
*/
|
|
43
46
|
var INNER_MATCHES = [
|
|
44
47
|
// Breaks on the slash - e.g. "651-234-2345/332-445-1234"
|
|
45
|
-
'
|
|
48
|
+
'/+(.*)',
|
|
46
49
|
// Note that the bracket here is inside the capturing group, since we consider it part of the
|
|
47
50
|
// phone number. Will match a pattern like "(650) 223 3345 (754) 223 3321".
|
|
48
51
|
'(\\([^(]*)', // Breaks on a hyphen - e.g. "12345 - 332-445-1234 is my number."
|
|
@@ -162,7 +165,12 @@ var PhoneNumberMatcher = exports["default"] = /*#__PURE__*/function () {
|
|
|
162
165
|
|
|
163
166
|
/** The maximum number of retries after matching an invalid number. */
|
|
164
167
|
this.maxTries = options.maxTries;
|
|
168
|
+
|
|
169
|
+
// Compile regular expressions.
|
|
165
170
|
this.PATTERN = new RegExp(PATTERN, 'ig');
|
|
171
|
+
this.INNER_MATCHES = INNER_MATCHES.map(function (pattern) {
|
|
172
|
+
return new RegExp(pattern, 'g');
|
|
173
|
+
});
|
|
166
174
|
|
|
167
175
|
/** The iteration tristate. */
|
|
168
176
|
this.state = 'NOT_READY';
|
|
@@ -186,10 +194,9 @@ var PhoneNumberMatcher = exports["default"] = /*#__PURE__*/function () {
|
|
|
186
194
|
*/
|
|
187
195
|
return _createClass(PhoneNumberMatcher, [{
|
|
188
196
|
key: "find",
|
|
189
|
-
value: function find() {
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
value: function find(index) {
|
|
198
|
+
// Reset the regular expression.
|
|
199
|
+
this.PATTERN.lastIndex = index;
|
|
193
200
|
var matches;
|
|
194
201
|
while (this.maxTries > 0 && (matches = this.PATTERN.exec(this.text)) !== null) {
|
|
195
202
|
var candidate = matches[0];
|
|
@@ -244,11 +251,12 @@ var PhoneNumberMatcher = exports["default"] = /*#__PURE__*/function () {
|
|
|
244
251
|
}, {
|
|
245
252
|
key: "extractInnerMatch",
|
|
246
253
|
value: function extractInnerMatch(substring, offset, text) {
|
|
247
|
-
for (var
|
|
248
|
-
var
|
|
254
|
+
for (var _iterator = _createForOfIteratorHelperLoose(this.INNER_MATCHES), _step; !(_step = _iterator()).done;) {
|
|
255
|
+
var innerMatchRegExp = _step.value;
|
|
256
|
+
// Reset regular expression.
|
|
257
|
+
innerMatchRegExp.lastIndex = 0;
|
|
249
258
|
var isFirstMatch = true;
|
|
250
259
|
var candidateMatch = void 0;
|
|
251
|
-
var innerMatchRegExp = new RegExp(innerMatchPattern, 'g');
|
|
252
260
|
while (this.maxTries > 0 && (candidateMatch = innerMatchRegExp.exec(substring)) !== null) {
|
|
253
261
|
if (isFirstMatch) {
|
|
254
262
|
// We should handle any group before this one too.
|
|
@@ -320,10 +328,9 @@ var PhoneNumberMatcher = exports["default"] = /*#__PURE__*/function () {
|
|
|
320
328
|
key: "hasNext",
|
|
321
329
|
value: function hasNext() {
|
|
322
330
|
if (this.state === 'NOT_READY') {
|
|
323
|
-
this.lastMatch = this.find(
|
|
324
|
-
|
|
331
|
+
this.lastMatch = this.find(this.searchIndex);
|
|
325
332
|
if (this.lastMatch) {
|
|
326
|
-
|
|
333
|
+
this.searchIndex = this.lastMatch.endsAt;
|
|
327
334
|
this.state = 'READY';
|
|
328
335
|
} else {
|
|
329
336
|
this.state = 'DONE';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneNumberMatcher.js","names":["_constants","require","_createExtensionPattern","_interopRequireDefault","_RegExpCache","_util","_utf","_Leniency","_parsePreCandidate","_isValidPreCandidate","_isValidCandidate","_interopRequireWildcard","_metadata","_parsePhoneNumber","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Symbol","iterator","constructor","prototype","_classCallCheck","a","TypeError","_defineProperties","length","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","String","Number","USE_NON_GEOGRAPHIC_COUNTRY_CODE","EXTN_PATTERNS_FOR_MATCHING","createExtensionPattern","INNER_MATCHES","concat","pZ","PZ","leadLimit","limit","punctuationLimit","digitBlockLimit","MAX_LENGTH_FOR_NSN","MAX_LENGTH_COUNTRY_CODE","blockLimit","punctuation","VALID_PUNCTUATION","digitSequence","pNd","PATTERN","LEAD_CLASS","UNWANTED_END_CHAR_PATTERN","RegExp","_pN","_pL","MAX_SAFE_INTEGER","Math","pow","PhoneNumberMatcher","exports","text","arguments","undefined","options","metadata","v2","defaultCallingCode","defaultCountry","isSupportedCountry","leniency","extended","maxTries","Leniency","state","searchIndex","regExpCache","RegExpCache","value","find","matches","exec","candidate","offset","index","parsePreCandidate","isValidPreCandidate","match","parseAndVerify","extractInnerMatch","startsAt","endsAt","number","phoneNumber","result","phone","nationalNumber","country","countryCallingCode","ext","substring","_i","_INNER_MATCHES","innerMatchPattern","isFirstMatch","candidateMatch","innerMatchRegExp","trimAfterFirstMatch","slice","candidateIndexGuess","indexOf","isValidCandidate","parsePhoneNumber","isPossible","hasNext","lastMatch","next","Error"],"sources":["../source/PhoneNumberMatcher.js"],"sourcesContent":["/**\r\n * A port of Google's `PhoneNumberMatcher.java`.\r\n * https://github.com/googlei18n/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java\r\n * Date: 08.03.2018.\r\n */\r\n\r\nimport {\r\n MAX_LENGTH_FOR_NSN,\r\n MAX_LENGTH_COUNTRY_CODE,\r\n VALID_PUNCTUATION\r\n} from './constants.js'\r\n\r\nimport createExtensionPattern from './helpers/extension/createExtensionPattern.js'\r\n\r\nimport RegExpCache from './findNumbers/RegExpCache.js'\r\n\r\nimport {\r\n\tlimit,\r\n\ttrimAfterFirstMatch\r\n} from './findNumbers/util.js'\r\n\r\nimport {\r\n\t_pL,\r\n\t_pN,\r\n\tpZ,\r\n\tPZ,\r\n\tpNd\r\n} from './findNumbers/utf-8.js'\r\n\r\nimport Leniency from './findNumbers/Leniency.js'\r\nimport parsePreCandidate from './findNumbers/parsePreCandidate.js'\r\nimport isValidPreCandidate from './findNumbers/isValidPreCandidate.js'\r\nimport isValidCandidate, { LEAD_CLASS } from './findNumbers/isValidCandidate.js'\r\n\r\nimport { isSupportedCountry } from './metadata.js'\r\n\r\nimport parsePhoneNumber from './parsePhoneNumber.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nconst EXTN_PATTERNS_FOR_MATCHING = createExtensionPattern('matching')\r\n\r\n/**\r\n * Patterns used to extract phone numbers from a larger phone-number-like pattern. These are\r\n * ordered according to specificity. For example, white-space is last since that is frequently\r\n * used in numbers, not just to separate two numbers. We have separate patterns since we don't\r\n * want to break up the phone-number-like text on more than one different kind of symbol at one\r\n * time, although symbols of the same type (e.g. space) can be safely grouped together.\r\n *\r\n * Note that if there is a match, we will always check any text found up to the first match as\r\n * well.\r\n */\r\nconst INNER_MATCHES =\r\n[\r\n\t// Breaks on the slash - e.g. \"651-234-2345/332-445-1234\"\r\n\t'\\\\/+(.*)/',\r\n\r\n\t// Note that the bracket here is inside the capturing group, since we consider it part of the\r\n\t// phone number. Will match a pattern like \"(650) 223 3345 (754) 223 3321\".\r\n\t'(\\\\([^(]*)',\r\n\r\n\t// Breaks on a hyphen - e.g. \"12345 - 332-445-1234 is my number.\"\r\n\t// We require a space on either side of the hyphen for it to be considered a separator.\r\n\t`(?:${pZ}-|-${pZ})${pZ}*(.+)`,\r\n\r\n\t// Various types of wide hyphens. Note we have decided not to enforce a space here, since it's\r\n\t// possible that it's supposed to be used to break two numbers without spaces, and we haven't\r\n\t// seen many instances of it used within a number.\r\n\t`[\\u2012-\\u2015\\uFF0D]${pZ}*(.+)`,\r\n\r\n\t// Breaks on a full stop - e.g. \"12345. 332-445-1234 is my number.\"\r\n\t`\\\\.+${pZ}*([^.]+)`,\r\n\r\n\t// Breaks on space - e.g. \"3324451234 8002341234\"\r\n\t`${pZ}+(${PZ}+)`\r\n]\r\n\r\n// Limit on the number of leading (plus) characters.\r\nconst leadLimit = limit(0, 2)\r\n\r\n// Limit on the number of consecutive punctuation characters.\r\nconst punctuationLimit = limit(0, 4)\r\n\r\n/* The maximum number of digits allowed in a digit-separated block. As we allow all digits in a\r\n * single block, set high enough to accommodate the entire national number and the international\r\n * country code. */\r\nconst digitBlockLimit = MAX_LENGTH_FOR_NSN + MAX_LENGTH_COUNTRY_CODE\r\n\r\n// Limit on the number of blocks separated by punctuation.\r\n// Uses digitBlockLimit since some formats use spaces to separate each digit.\r\nconst blockLimit = limit(0, digitBlockLimit)\r\n\r\n/* A punctuation sequence allowing white space. */\r\nconst punctuation = `[${VALID_PUNCTUATION}]` + punctuationLimit\r\n\r\n// A digits block without punctuation.\r\nconst digitSequence = pNd + limit(1, digitBlockLimit)\r\n\r\n/**\r\n * Phone number pattern allowing optional punctuation.\r\n * The phone number pattern used by `find()`, similar to\r\n * VALID_PHONE_NUMBER, but with the following differences:\r\n * <ul>\r\n * <li>All captures are limited in order to place an upper bound to the text matched by the\r\n * pattern.\r\n * <ul>\r\n * <li>Leading punctuation / plus signs are limited.\r\n * <li>Consecutive occurrences of punctuation are limited.\r\n * <li>Number of digits is limited.\r\n * </ul>\r\n * <li>No whitespace is allowed at the start or end.\r\n * <li>No alpha digits (vanity numbers such as 1-800-SIX-FLAGS) are currently supported.\r\n * </ul>\r\n */\r\nconst PATTERN = '(?:' + LEAD_CLASS + punctuation + ')' + leadLimit\r\n\t+ digitSequence + '(?:' + punctuation + digitSequence + ')' + blockLimit\r\n\t+ '(?:' + EXTN_PATTERNS_FOR_MATCHING + ')?'\r\n\r\n// Regular expression of trailing characters that we want to remove.\r\n// We remove all characters that are not alpha or numerical characters.\r\n// The hash character is retained here, as it may signify\r\n// the previous block was an extension.\r\n//\r\n// // Don't know what does '&&' mean here.\r\n// const UNWANTED_END_CHAR_PATTERN = new RegExp(`[[\\\\P{N}&&\\\\P{L}]&&[^#]]+$`)\r\n//\r\nconst UNWANTED_END_CHAR_PATTERN = new RegExp(`[^${_pN}${_pL}#]+$`)\r\n\r\n// const NON_DIGITS_PATTERN = /(\\D+)/\r\n\r\nconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1\r\n\r\n/**\r\n * A stateful class that finds and extracts telephone numbers from {@linkplain CharSequence text}.\r\n * Instances can be created using the {@linkplain PhoneNumberUtil#findNumbers factory methods} in\r\n * {@link PhoneNumberUtil}.\r\n *\r\n * <p>Vanity numbers (phone numbers using alphabetic digits such as <tt>1-800-SIX-FLAGS</tt> are\r\n * not found.\r\n *\r\n * <p>This class is not thread-safe.\r\n */\r\nexport default class PhoneNumberMatcher\r\n{\r\n /**\r\n * @param {string} text — the character sequence that we will search, null for no text.\r\n * @param {'POSSIBLE'|'VALID'|'STRICT_GROUPING'|'EXACT_GROUPING'} [options.leniency] — The leniency to use when evaluating candidate phone numbers. See `source/findNumbers/Leniency.js` for more details.\r\n * @param {number} [options.maxTries] — The maximum number of invalid numbers to try before giving up on the text. This is to cover degenerate cases where the text has a lot of false positives in it. Must be >= 0.\r\n */\r\n constructor(text = '', options = {}, metadata)\r\n {\r\n options = {\r\n v2: options.v2,\r\n defaultCallingCode: options.defaultCallingCode,\r\n defaultCountry: options.defaultCountry && isSupportedCountry(options.defaultCountry, metadata) ? options.defaultCountry : undefined,\r\n // Here it should've assigned a default value only if `options.leniency === undefined`.\r\n leniency: options.leniency || (options.extended ? 'POSSIBLE' : 'VALID'),\r\n // Here it should've assigned a default value only if `options.maxTries === undefined`.\r\n maxTries: options.maxTries || MAX_SAFE_INTEGER\r\n }\r\n\r\n // Validate `leniency`.\r\n\t\t// if (!options.leniency) {\r\n\t\t// \tthrow new TypeError('`leniency` is required')\r\n\t\t// }\r\n\t\tif (!Leniency[options.leniency]) {\r\n\t\t\tthrow new TypeError(`Unknown leniency: \"${options.leniency}\"`)\r\n\t\t}\r\n if (options.leniency !== 'POSSIBLE' && options.leniency !== 'VALID') {\r\n throw new TypeError(`Invalid \\`leniency\\`: \"${options.leniency}\". Supported values: \"POSSIBLE\", \"VALID\".`)\r\n }\r\n\r\n // Validate `maxTries`.\r\n\t\tif (options.maxTries < 0) {\r\n\t\t\tthrow new TypeError('`maxTries` must be `>= 0`')\r\n\t\t}\r\n\r\n\t\tthis.text = text\r\n\t\tthis.options = options\r\n this.metadata = metadata\r\n\r\n\t\t// The degree of phone number validation.\r\n\t\tthis.leniency = Leniency[options.leniency]\r\n\r\n\t\t/** The maximum number of retries after matching an invalid number. */\r\n\t\tthis.maxTries = options.maxTries\r\n\r\n\t\tthis.PATTERN = new RegExp(PATTERN, 'ig')\r\n\r\n /** The iteration tristate. */\r\n this.state = 'NOT_READY'\r\n\r\n /** The next index to start searching at. Undefined in {@link State#DONE}. */\r\n this.searchIndex = 0\r\n\r\n // A cache for frequently used country-specific regular expressions. Set to 32 to cover ~2-3\r\n // countries being used for the same doc with ~10 patterns for each country. Some pages will have\r\n // a lot more countries in use, but typically fewer numbers for each so expanding the cache for\r\n // that use-case won't have a lot of benefit.\r\n this.regExpCache = new RegExpCache(32)\r\n }\r\n\r\n /**\r\n * Attempts to find the next subsequence in the searched sequence on or after {@code searchIndex}\r\n * that represents a phone number. Returns the next match, null if none was found.\r\n *\r\n * @param index the search index to start searching at\r\n * @return the phone number match found, null if none can be found\r\n */\r\n\tfind() {\r\n\t\t// // Reset the regular expression.\r\n\t\t// this.PATTERN.lastIndex = index\r\n\r\n\t\tlet matches\r\n\t\twhile ((this.maxTries > 0) && (matches = this.PATTERN.exec(this.text)) !== null) {\r\n\t\t\tlet candidate = matches[0]\r\n\t\t\tconst offset = matches.index\r\n\r\n\t\t\tcandidate = parsePreCandidate(candidate)\r\n\r\n\t\t\tif (isValidPreCandidate(candidate, offset, this.text)) {\r\n\t\t\t\tconst match =\r\n\t\t\t\t\t// Try to come up with a valid match given the entire candidate.\r\n\t\t\t\t\tthis.parseAndVerify(candidate, offset, this.text)\r\n\t\t\t\t\t// If that failed, try to find an \"inner match\" -\r\n\t\t\t\t\t// there might be a phone number within this candidate.\r\n\t\t\t\t\t|| this.extractInnerMatch(candidate, offset, this.text)\r\n\r\n\t\t\t\tif (match) {\r\n\t\t\t\t\tif (this.options.v2) {\r\n\t\t\t\t\t\treturn {\r\n\t\t\t\t\t\t\tstartsAt: match.startsAt,\r\n\t\t\t\t\t\t\tendsAt: match.endsAt,\r\n\t\t\t\t\t\t\tnumber: match.phoneNumber\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else {\r\n const { phoneNumber } = match\r\n\r\n const result = {\r\n startsAt: match.startsAt,\r\n endsAt: match.endsAt,\r\n phone: phoneNumber.nationalNumber\r\n }\r\n\r\n if (phoneNumber.country) {\r\n /* istanbul ignore if */\r\n if (USE_NON_GEOGRAPHIC_COUNTRY_CODE && country === '001') {\r\n result.countryCallingCode = phoneNumber.countryCallingCode\r\n } else {\r\n result.country = phoneNumber.country\r\n }\r\n } else {\r\n result.countryCallingCode = phoneNumber.countryCallingCode\r\n }\r\n\r\n if (phoneNumber.ext) {\r\n result.ext = phoneNumber.ext\r\n }\r\n\r\n return result\r\n }\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tthis.maxTries--\r\n\t\t}\r\n\t}\r\n\r\n /**\r\n * Attempts to extract a match from `substring`\r\n * if the substring itself does not qualify as a match.\r\n */\r\n extractInnerMatch(substring, offset, text) {\r\n for (const innerMatchPattern of INNER_MATCHES) {\r\n let isFirstMatch = true\r\n let candidateMatch\r\n const innerMatchRegExp = new RegExp(innerMatchPattern, 'g')\r\n while (this.maxTries > 0 && (candidateMatch = innerMatchRegExp.exec(substring)) !== null) {\r\n if (isFirstMatch) {\r\n // We should handle any group before this one too.\r\n const candidate = trimAfterFirstMatch(\r\n UNWANTED_END_CHAR_PATTERN,\r\n substring.slice(0, candidateMatch.index)\r\n )\r\n\r\n const match = this.parseAndVerify(candidate, offset, text)\r\n\r\n if (match) {\r\n return match\r\n }\r\n\r\n this.maxTries--\r\n isFirstMatch = false\r\n }\r\n\r\n const candidate = trimAfterFirstMatch(UNWANTED_END_CHAR_PATTERN, candidateMatch[1])\r\n\r\n // Java code does `groupMatcher.start(1)` here,\r\n // but there's no way in javascript to get a `candidate` start index,\r\n // therefore resort to using this kind of an approximation.\r\n // (`groupMatcher` is called `candidateInSubstringMatch` in this javascript port)\r\n // https://stackoverflow.com/questions/15934353/get-index-of-each-capture-in-a-javascript-regex\r\n const candidateIndexGuess = substring.indexOf(candidate, candidateMatch.index)\r\n\r\n const match = this.parseAndVerify(candidate, offset + candidateIndexGuess, text)\r\n if (match) {\r\n return match\r\n }\r\n\r\n this.maxTries--\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Parses a phone number from the `candidate` using `parse` and\r\n * verifies it matches the requested `leniency`. If parsing and verification succeed,\r\n * a corresponding `PhoneNumberMatch` is returned, otherwise this method returns `null`.\r\n *\r\n * @param candidate the candidate match\r\n * @param offset the offset of {@code candidate} within {@link #text}\r\n * @return the parsed and validated phone number match, or null\r\n */\r\n parseAndVerify(candidate, offset, text) {\r\n if (!isValidCandidate(candidate, offset, text, this.options.leniency)) {\r\n return\r\n \t}\r\n\r\n const phoneNumber = parsePhoneNumber(\r\n candidate,\r\n {\r\n extended: true,\r\n defaultCountry: this.options.defaultCountry,\r\n defaultCallingCode: this.options.defaultCallingCode\r\n },\r\n this.metadata\r\n )\r\n\r\n if (!phoneNumber) {\r\n return\r\n }\r\n\r\n if (!phoneNumber.isPossible()) {\r\n return\r\n }\r\n\r\n if (this.leniency(phoneNumber, {\r\n candidate,\r\n defaultCountry: this.options.defaultCountry,\r\n metadata: this.metadata,\r\n regExpCache: this.regExpCache\r\n })) {\r\n return {\r\n startsAt: offset,\r\n endsAt: offset + candidate.length,\r\n phoneNumber\r\n }\r\n }\r\n }\r\n\r\n hasNext()\r\n {\r\n if (this.state === 'NOT_READY')\r\n {\r\n this.lastMatch = this.find() // (this.searchIndex)\r\n\r\n if (this.lastMatch)\r\n {\r\n // this.searchIndex = this.lastMatch.endsAt\r\n this.state = 'READY'\r\n }\r\n else\r\n {\r\n this.state = 'DONE'\r\n }\r\n }\r\n\r\n return this.state === 'READY'\r\n }\r\n\r\n next()\r\n {\r\n // Check the state and find the next match as a side-effect if necessary.\r\n if (!this.hasNext())\r\n {\r\n throw new Error('No next element')\r\n }\r\n\r\n // Don't retain that memory any longer than necessary.\r\n const result = this.lastMatch\r\n this.lastMatch = null\r\n this.state = 'NOT_READY'\r\n return result\r\n }\r\n}"],"mappings":";;;;;;AAMA,IAAAA,UAAA,GAAAC,OAAA;AAMA,IAAAC,uBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,IAAA,GAAAL,OAAA;AAQA,IAAAM,SAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,kBAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,oBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,iBAAA,GAAAC,uBAAA,CAAAV,OAAA;AAEA,IAAAW,SAAA,GAAAX,OAAA;AAEA,IAAAY,iBAAA,GAAAV,sBAAA,CAAAF,OAAA;AAAoD,SAAAU,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,wBAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAA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A,IAAI,CAACzC,KAAK,GAAG,OAAO;QACtB,CAAC,MAED;UACE,IAAI,CAACA,KAAK,GAAG,MAAM;QACrB;MACF;MAEA,OAAO,IAAI,CAACA,KAAK,KAAK,OAAO;IAC/B;EAAC;IAAAhD,GAAA;IAAAoD,KAAA,EAED,SAAAsC,IAAIA,CAAA,EACJ;MACE;MACA,IAAI,CAAC,IAAI,CAACF,OAAO,CAAC,CAAC,EACnB;QACE,MAAM,IAAIG,KAAK,CAAC,iBAAiB,CAAC;MACpC;;MAEA;MACA,IAAMvB,MAAM,GAAG,IAAI,CAACqB,SAAS;MAC7B,IAAI,CAACA,SAAS,GAAG,IAAI;MACrB,IAAI,CAACzC,KAAK,GAAG,WAAW;MACxB,OAAOoB,MAAM;IACf;EAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PhoneNumberMatcher.js","names":["_constants","require","_createExtensionPattern","_interopRequireDefault","_RegExpCache","_util","_utf","_Leniency","_parsePreCandidate","_isValidPreCandidate","_isValidCandidate","_interopRequireWildcard","_metadata","_parsePhoneNumber","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Symbol","iterator","constructor","prototype","_createForOfIteratorHelperLoose","next","bind","Array","isArray","_unsupportedIterableToArray","length","done","value","TypeError","a","_arrayLikeToArray","toString","slice","name","from","test","_classCallCheck","_defineProperties","enumerable","configurable","writable","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","String","Number","USE_NON_GEOGRAPHIC_COUNTRY_CODE","EXTN_PATTERNS_FOR_MATCHING","createExtensionPattern","INNER_MATCHES","concat","pZ","PZ","leadLimit","limit","punctuationLimit","digitBlockLimit","MAX_LENGTH_FOR_NSN","MAX_LENGTH_COUNTRY_CODE","blockLimit","punctuation","VALID_PUNCTUATION","digitSequence","pNd","PATTERN","LEAD_CLASS","UNWANTED_END_CHAR_PATTERN","RegExp","_pN","_pL","MAX_SAFE_INTEGER","Math","pow","PhoneNumberMatcher","exports","text","arguments","undefined","options","metadata","v2","defaultCallingCode","defaultCountry","isSupportedCountry","leniency","extended","maxTries","Leniency","map","pattern","state","searchIndex","regExpCache","RegExpCache","find","index","lastIndex","matches","exec","candidate","offset","parsePreCandidate","isValidPreCandidate","match","parseAndVerify","extractInnerMatch","startsAt","endsAt","number","phoneNumber","result","phone","nationalNumber","country","countryCallingCode","ext","substring","_iterator","_step","innerMatchRegExp","isFirstMatch","candidateMatch","trimAfterFirstMatch","candidateIndexGuess","indexOf","isValidCandidate","parsePhoneNumber","isPossible","hasNext","lastMatch","Error"],"sources":["../source/PhoneNumberMatcher.js"],"sourcesContent":["/**\r\n * A port of Google's `PhoneNumberMatcher.java`.\r\n * https://github.com/googlei18n/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java\r\n * Date: 08.03.2018.\r\n */\r\n\r\nimport {\r\n MAX_LENGTH_FOR_NSN,\r\n MAX_LENGTH_COUNTRY_CODE,\r\n VALID_PUNCTUATION\r\n} from './constants.js'\r\n\r\nimport createExtensionPattern from './helpers/extension/createExtensionPattern.js'\r\n\r\nimport RegExpCache from './findNumbers/RegExpCache.js'\r\n\r\nimport {\r\n\tlimit,\r\n\ttrimAfterFirstMatch\r\n} from './findNumbers/util.js'\r\n\r\nimport {\r\n\t_pL,\r\n\t_pN,\r\n\tpZ,\r\n\tPZ,\r\n\tpNd\r\n} from './findNumbers/utf-8.js'\r\n\r\nimport Leniency from './findNumbers/Leniency.js'\r\nimport parsePreCandidate from './findNumbers/parsePreCandidate.js'\r\nimport isValidPreCandidate from './findNumbers/isValidPreCandidate.js'\r\nimport isValidCandidate, { LEAD_CLASS } from './findNumbers/isValidCandidate.js'\r\n\r\nimport { isSupportedCountry } from './metadata.js'\r\n\r\nimport parsePhoneNumber from './parsePhoneNumber.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nconst EXTN_PATTERNS_FOR_MATCHING = createExtensionPattern('matching')\r\n\r\n/**\r\n * Patterns used to extract phone numbers from a larger phone-number-like pattern. These are\r\n * ordered according to specificity. For example, white-space is last since that is frequently\r\n * used in numbers, not just to separate two numbers. We have separate patterns since we don't\r\n * want to break up the phone-number-like text on more than one different kind of symbol at one\r\n * time, although symbols of the same type (e.g. space) can be safely grouped together.\r\n *\r\n * Note that if there is a match, we will always check any text found up to the first match as\r\n * well.\r\n */\r\nconst INNER_MATCHES =\r\n[\r\n\t// Breaks on the slash - e.g. \"651-234-2345/332-445-1234\"\r\n\t'/+(.*)',\r\n\r\n\t// Note that the bracket here is inside the capturing group, since we consider it part of the\r\n\t// phone number. Will match a pattern like \"(650) 223 3345 (754) 223 3321\".\r\n\t'(\\\\([^(]*)',\r\n\r\n\t// Breaks on a hyphen - e.g. \"12345 - 332-445-1234 is my number.\"\r\n\t// We require a space on either side of the hyphen for it to be considered a separator.\r\n\t`(?:${pZ}-|-${pZ})${pZ}*(.+)`,\r\n\r\n\t// Various types of wide hyphens. Note we have decided not to enforce a space here, since it's\r\n\t// possible that it's supposed to be used to break two numbers without spaces, and we haven't\r\n\t// seen many instances of it used within a number.\r\n\t`[\\u2012-\\u2015\\uFF0D]${pZ}*(.+)`,\r\n\r\n\t// Breaks on a full stop - e.g. \"12345. 332-445-1234 is my number.\"\r\n\t`\\\\.+${pZ}*([^.]+)`,\r\n\r\n\t// Breaks on space - e.g. \"3324451234 8002341234\"\r\n\t`${pZ}+(${PZ}+)`\r\n]\r\n\r\n// Limit on the number of leading (plus) characters.\r\nconst leadLimit = limit(0, 2)\r\n\r\n// Limit on the number of consecutive punctuation characters.\r\nconst punctuationLimit = limit(0, 4)\r\n\r\n/* The maximum number of digits allowed in a digit-separated block. As we allow all digits in a\r\n * single block, set high enough to accommodate the entire national number and the international\r\n * country code. */\r\nconst digitBlockLimit = MAX_LENGTH_FOR_NSN + MAX_LENGTH_COUNTRY_CODE\r\n\r\n// Limit on the number of blocks separated by punctuation.\r\n// Uses digitBlockLimit since some formats use spaces to separate each digit.\r\nconst blockLimit = limit(0, digitBlockLimit)\r\n\r\n/* A punctuation sequence allowing white space. */\r\nconst punctuation = `[${VALID_PUNCTUATION}]` + punctuationLimit\r\n\r\n// A digits block without punctuation.\r\nconst digitSequence = pNd + limit(1, digitBlockLimit)\r\n\r\n/**\r\n * Phone number pattern allowing optional punctuation.\r\n * The phone number pattern used by `find()`, similar to\r\n * VALID_PHONE_NUMBER, but with the following differences:\r\n * <ul>\r\n * <li>All captures are limited in order to place an upper bound to the text matched by the\r\n * pattern.\r\n * <ul>\r\n * <li>Leading punctuation / plus signs are limited.\r\n * <li>Consecutive occurrences of punctuation are limited.\r\n * <li>Number of digits is limited.\r\n * </ul>\r\n * <li>No whitespace is allowed at the start or end.\r\n * <li>No alpha digits (vanity numbers such as 1-800-SIX-FLAGS) are currently supported.\r\n * </ul>\r\n */\r\nconst PATTERN = '(?:' + LEAD_CLASS + punctuation + ')' + leadLimit\r\n\t+ digitSequence + '(?:' + punctuation + digitSequence + ')' + blockLimit\r\n\t+ '(?:' + EXTN_PATTERNS_FOR_MATCHING + ')?'\r\n\r\n// Regular expression of trailing characters that we want to remove.\r\n// We remove all characters that are not alpha or numerical characters.\r\n// The hash character is retained here, as it may signify\r\n// the previous block was an extension.\r\n//\r\n// // Don't know what does '&&' mean here.\r\n// const UNWANTED_END_CHAR_PATTERN = new RegExp(`[[\\\\P{N}&&\\\\P{L}]&&[^#]]+$`)\r\n//\r\nconst UNWANTED_END_CHAR_PATTERN = new RegExp(`[^${_pN}${_pL}#]+$`)\r\n\r\n// const NON_DIGITS_PATTERN = /(\\D+)/\r\n\r\nconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1\r\n\r\n/**\r\n * A stateful class that finds and extracts telephone numbers from {@linkplain CharSequence text}.\r\n * Instances can be created using the {@linkplain PhoneNumberUtil#findNumbers factory methods} in\r\n * {@link PhoneNumberUtil}.\r\n *\r\n * <p>Vanity numbers (phone numbers using alphabetic digits such as <tt>1-800-SIX-FLAGS</tt> are\r\n * not found.\r\n *\r\n * <p>This class is not thread-safe.\r\n */\r\nexport default class PhoneNumberMatcher\r\n{\r\n /**\r\n * @param {string} text — the character sequence that we will search, null for no text.\r\n * @param {'POSSIBLE'|'VALID'|'STRICT_GROUPING'|'EXACT_GROUPING'} [options.leniency] — The leniency to use when evaluating candidate phone numbers. See `source/findNumbers/Leniency.js` for more details.\r\n * @param {number} [options.maxTries] — The maximum number of invalid numbers to try before giving up on the text. This is to cover degenerate cases where the text has a lot of false positives in it. Must be >= 0.\r\n */\r\n constructor(text = '', options = {}, metadata)\r\n {\r\n options = {\r\n v2: options.v2,\r\n defaultCallingCode: options.defaultCallingCode,\r\n defaultCountry: options.defaultCountry && isSupportedCountry(options.defaultCountry, metadata) ? options.defaultCountry : undefined,\r\n // Here it should've assigned a default value only if `options.leniency === undefined`.\r\n leniency: options.leniency || (options.extended ? 'POSSIBLE' : 'VALID'),\r\n // Here it should've assigned a default value only if `options.maxTries === undefined`.\r\n maxTries: options.maxTries || MAX_SAFE_INTEGER\r\n }\r\n\r\n // Validate `leniency`.\r\n\t\t// if (!options.leniency) {\r\n\t\t// \tthrow new TypeError('`leniency` is required')\r\n\t\t// }\r\n\t\tif (!Leniency[options.leniency]) {\r\n\t\t\tthrow new TypeError(`Unknown leniency: \"${options.leniency}\"`)\r\n\t\t}\r\n if (options.leniency !== 'POSSIBLE' && options.leniency !== 'VALID') {\r\n throw new TypeError(`Invalid \\`leniency\\`: \"${options.leniency}\". Supported values: \"POSSIBLE\", \"VALID\".`)\r\n }\r\n\r\n // Validate `maxTries`.\r\n\t\tif (options.maxTries < 0) {\r\n\t\t\tthrow new TypeError('`maxTries` must be `>= 0`')\r\n\t\t}\r\n\r\n\t\tthis.text = text\r\n\t\tthis.options = options\r\n this.metadata = metadata\r\n\r\n\t\t// The degree of phone number validation.\r\n\t\tthis.leniency = Leniency[options.leniency]\r\n\r\n\t\t/** The maximum number of retries after matching an invalid number. */\r\n\t\tthis.maxTries = options.maxTries\r\n\r\n // Compile regular expressions.\r\n\t\tthis.PATTERN = new RegExp(PATTERN, 'ig')\r\n this.INNER_MATCHES = INNER_MATCHES.map(pattern => new RegExp(pattern, 'g'))\r\n\r\n /** The iteration tristate. */\r\n this.state = 'NOT_READY'\r\n\r\n /** The next index to start searching at. Undefined in {@link State#DONE}. */\r\n this.searchIndex = 0\r\n\r\n // A cache for frequently used country-specific regular expressions. Set to 32 to cover ~2-3\r\n // countries being used for the same doc with ~10 patterns for each country. Some pages will have\r\n // a lot more countries in use, but typically fewer numbers for each so expanding the cache for\r\n // that use-case won't have a lot of benefit.\r\n this.regExpCache = new RegExpCache(32)\r\n }\r\n\r\n /**\r\n * Attempts to find the next subsequence in the searched sequence on or after {@code searchIndex}\r\n * that represents a phone number. Returns the next match, null if none was found.\r\n *\r\n * @param index the search index to start searching at\r\n * @return the phone number match found, null if none can be found\r\n */\r\n\tfind(index) {\r\n\t\t// Reset the regular expression.\r\n\t\tthis.PATTERN.lastIndex = index\r\n\r\n\t\tlet matches\r\n\t\twhile ((this.maxTries > 0) && (matches = this.PATTERN.exec(this.text)) !== null) {\r\n\t\t\tlet candidate = matches[0]\r\n\t\t\tconst offset = matches.index\r\n\r\n\t\t\tcandidate = parsePreCandidate(candidate)\r\n\r\n\t\t\tif (isValidPreCandidate(candidate, offset, this.text)) {\r\n\t\t\t\tconst match =\r\n\t\t\t\t\t// Try to come up with a valid match given the entire candidate.\r\n\t\t\t\t\tthis.parseAndVerify(candidate, offset, this.text)\r\n\t\t\t\t\t// If that failed, try to find an \"inner match\" -\r\n\t\t\t\t\t// there might be a phone number within this candidate.\r\n\t\t\t\t\t|| this.extractInnerMatch(candidate, offset, this.text)\r\n\r\n\t\t\t\tif (match) {\r\n\t\t\t\t\tif (this.options.v2) {\r\n\t\t\t\t\t\treturn {\r\n\t\t\t\t\t\t\tstartsAt: match.startsAt,\r\n\t\t\t\t\t\t\tendsAt: match.endsAt,\r\n\t\t\t\t\t\t\tnumber: match.phoneNumber\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else {\r\n const { phoneNumber } = match\r\n\r\n const result = {\r\n startsAt: match.startsAt,\r\n endsAt: match.endsAt,\r\n phone: phoneNumber.nationalNumber\r\n }\r\n\r\n if (phoneNumber.country) {\r\n /* istanbul ignore if */\r\n if (USE_NON_GEOGRAPHIC_COUNTRY_CODE && country === '001') {\r\n result.countryCallingCode = phoneNumber.countryCallingCode\r\n } else {\r\n result.country = phoneNumber.country\r\n }\r\n } else {\r\n result.countryCallingCode = phoneNumber.countryCallingCode\r\n }\r\n\r\n if (phoneNumber.ext) {\r\n result.ext = phoneNumber.ext\r\n }\r\n\r\n return result\r\n }\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tthis.maxTries--\r\n\t\t}\r\n\t}\r\n\r\n /**\r\n * Attempts to extract a match from `substring`\r\n * if the substring itself does not qualify as a match.\r\n */\r\n extractInnerMatch(substring, offset, text) {\r\n for (const innerMatchRegExp of this.INNER_MATCHES) {\r\n // Reset regular expression.\r\n innerMatchRegExp.lastIndex = 0\r\n\r\n let isFirstMatch = true\r\n let candidateMatch\r\n while (this.maxTries > 0 && (candidateMatch = innerMatchRegExp.exec(substring)) !== null) {\r\n if (isFirstMatch) {\r\n // We should handle any group before this one too.\r\n const candidate = trimAfterFirstMatch(\r\n UNWANTED_END_CHAR_PATTERN,\r\n substring.slice(0, candidateMatch.index)\r\n )\r\n\r\n const match = this.parseAndVerify(candidate, offset, text)\r\n\r\n if (match) {\r\n return match\r\n }\r\n\r\n this.maxTries--\r\n isFirstMatch = false\r\n }\r\n\r\n const candidate = trimAfterFirstMatch(UNWANTED_END_CHAR_PATTERN, candidateMatch[1])\r\n\r\n // Java code does `groupMatcher.start(1)` here,\r\n // but there's no way in javascript to get a `candidate` start index,\r\n // therefore resort to using this kind of an approximation.\r\n // (`groupMatcher` is called `candidateInSubstringMatch` in this javascript port)\r\n // https://stackoverflow.com/questions/15934353/get-index-of-each-capture-in-a-javascript-regex\r\n const candidateIndexGuess = substring.indexOf(candidate, candidateMatch.index)\r\n\r\n const match = this.parseAndVerify(candidate, offset + candidateIndexGuess, text)\r\n if (match) {\r\n return match\r\n }\r\n\r\n this.maxTries--\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Parses a phone number from the `candidate` using `parse` and\r\n * verifies it matches the requested `leniency`. If parsing and verification succeed,\r\n * a corresponding `PhoneNumberMatch` is returned, otherwise this method returns `null`.\r\n *\r\n * @param candidate the candidate match\r\n * @param offset the offset of {@code candidate} within {@link #text}\r\n * @return the parsed and validated phone number match, or null\r\n */\r\n parseAndVerify(candidate, offset, text) {\r\n if (!isValidCandidate(candidate, offset, text, this.options.leniency)) {\r\n return\r\n \t}\r\n\r\n const phoneNumber = parsePhoneNumber(\r\n candidate,\r\n {\r\n extended: true,\r\n defaultCountry: this.options.defaultCountry,\r\n defaultCallingCode: this.options.defaultCallingCode\r\n },\r\n this.metadata\r\n )\r\n\r\n if (!phoneNumber) {\r\n return\r\n }\r\n\r\n if (!phoneNumber.isPossible()) {\r\n return\r\n }\r\n\r\n if (this.leniency(phoneNumber, {\r\n candidate,\r\n defaultCountry: this.options.defaultCountry,\r\n metadata: this.metadata,\r\n regExpCache: this.regExpCache\r\n })) {\r\n return {\r\n startsAt: offset,\r\n endsAt: offset + candidate.length,\r\n phoneNumber\r\n }\r\n }\r\n }\r\n\r\n hasNext()\r\n {\r\n if (this.state === 'NOT_READY')\r\n {\r\n this.lastMatch = this.find(this.searchIndex)\r\n\r\n if (this.lastMatch)\r\n {\r\n this.searchIndex = this.lastMatch.endsAt\r\n this.state = 'READY'\r\n }\r\n else\r\n {\r\n this.state = 'DONE'\r\n }\r\n }\r\n\r\n return this.state === 'READY'\r\n }\r\n\r\n next()\r\n {\r\n // Check the state and find the next match as a side-effect if necessary.\r\n if (!this.hasNext())\r\n {\r\n throw new Error('No next element')\r\n }\r\n\r\n // Don't retain that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ACA,KAAK,KAAK,OAAO;IAC/B;EAAC;IAAAlD,GAAA;IAAAf,KAAA,EAED,SAAAP,IAAIA,CAAA,EACJ;MACE;MACA,IAAI,CAAC,IAAI,CAAC8G,OAAO,CAAC,CAAC,EACnB;QACE,MAAM,IAAIE,KAAK,CAAC,iBAAiB,CAAC;MACpC;;MAEA;MACA,IAAMpB,MAAM,GAAG,IAAI,CAACmB,SAAS;MAC7B,IAAI,CAACA,SAAS,GAAG,IAAI;MACrB,IAAI,CAACvC,KAAK,GAAG,WAAW;MACxB,OAAOoB,MAAM;IACf;EAAC;AAAA","ignoreList":[]}
|
|
@@ -101,5 +101,20 @@ describe('PhoneNumberMatcher', function () {
|
|
|
101
101
|
return matcher.next();
|
|
102
102
|
}).to["throw"]('No next element');
|
|
103
103
|
});
|
|
104
|
+
it('should find phone numbers that are separated by a slash', function () {
|
|
105
|
+
var matcher = new _PhoneNumberMatcher["default"]('651-234-2345/332-445-1234', {
|
|
106
|
+
defaultCountry: 'US',
|
|
107
|
+
v2: true
|
|
108
|
+
}, _metadataMin["default"]);
|
|
109
|
+
expect(matcher.hasNext()).to.equal(true);
|
|
110
|
+
var number1 = matcher.next();
|
|
111
|
+
expect(number1.startsAt).to.equal(0);
|
|
112
|
+
expect(number1.number.number).to.equal('+16512342345');
|
|
113
|
+
expect(matcher.hasNext()).to.equal(true);
|
|
114
|
+
var number2 = matcher.next();
|
|
115
|
+
expect(number2.startsAt).to.equal(13);
|
|
116
|
+
expect(number2.number.number).to.equal('+13324451234');
|
|
117
|
+
expect(matcher.hasNext()).to.equal(false);
|
|
118
|
+
});
|
|
104
119
|
});
|
|
105
120
|
//# sourceMappingURL=PhoneNumberMatcher.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneNumberMatcher.test.js","names":["_PhoneNumberMatcher","_interopRequireDefault","require","_metadataMin","e","__esModule","test","text","defaultCountry","expectedNumbers","nationalNumber","matcher","PhoneNumberMatcher","v2","metadata","hasNext","number","next","phoneNumber","shift","startsAt","undefined","expect","to","equal","endsAt","country","length","describe","it","leniency","maxTries"],"sources":["../source/PhoneNumberMatcher.test.js"],"sourcesContent":["import PhoneNumberMatcher from './PhoneNumberMatcher.js'\r\nimport metadata from '../metadata.min.json' with { type: 'json' }\r\n\r\nfunction test(text, defaultCountry, expectedNumbers) {\r\n\tif (typeof expectedNumbers === 'string') {\r\n\t\texpectedNumbers = [{\r\n\t\t\tnationalNumber: expectedNumbers\r\n\t\t}]\r\n\t}\r\n\tconst matcher = new PhoneNumberMatcher(text, { defaultCountry, v2: true }, metadata)\r\n\twhile (matcher.hasNext()) {\r\n\t\tconst number = matcher.next()\r\n\t\tconst phoneNumber = expectedNumbers.shift()\r\n\t\tif (phoneNumber.startsAt !== undefined) {\r\n\t\t\texpect(number.startsAt).to.equal(phoneNumber.startsAt)\r\n\t\t}\r\n\t\tif (phoneNumber.endsAt !== undefined) {\r\n\t\t\texpect(number.endsAt).to.equal(phoneNumber.endsAt)\r\n\t\t}\r\n\t\texpect(number.number.country).to.equal(phoneNumber.country || defaultCountry)\r\n\t\texpect(number.number.nationalNumber).to.equal(phoneNumber.nationalNumber)\r\n\t}\r\n\texpect(expectedNumbers.length).to.equal(0)\r\n}\r\n\r\ndescribe('PhoneNumberMatcher', () => {\r\n\tit('should find phone numbers', () => {\r\n\t\ttest(\r\n\t\t\t'The number is +7 (800) 555-35-35 and not (213) 373-4253 as written in the document.',\r\n\t\t\t'US',\r\n\t\t\t[{\r\n\t\t\t\tcountry: 'RU',\r\n\t\t\t\tnationalNumber: '8005553535',\r\n\t\t\t\tstartsAt: 14,\r\n\t\t\t\tendsAt: 32\r\n\t\t\t}, {\r\n\t\t\t\tcountry: 'US',\r\n\t\t\t\tnationalNumber: '2133734253',\r\n\t\t\t\tstartsAt: 41,\r\n\t\t\t\tendsAt: 55\r\n\t\t\t}]\r\n\t\t)\r\n\t})\r\n\r\n\tit('should find phone numbers from Mexico', () => {\r\n\t\t// Test parsing fixed-line numbers of Mexico.\r\n\t\ttest('+52 (449)978-0001', 'MX', '4499780001')\r\n\t\ttest('01 (449)978-0001', 'MX', '4499780001')\r\n\t\ttest('(449)978-0001', 'MX', '4499780001')\r\n\r\n\t\t// \"Dialling tokens 01, 02, 044, 045 and 1 are removed as they are\r\n\t\t// no longer valid since August 2019.\"\r\n\t\t// // Test parsing mobile numbers of Mexico.\r\n\t\t// test('+52 1 33 1234-5678', 'MX', '3312345678')\r\n\t\t// test('044 (33) 1234-5678', 'MX', '3312345678')\r\n\t\t// test('045 33 1234-5678', 'MX', '3312345678')\r\n\t})\r\n\r\n\tit('should find phone numbers from Argentina', () => {\r\n\t\t// Test parsing mobile numbers of Argentina.\r\n\t\ttest('+54 9 343 555 1212', 'AR', '93435551212')\r\n\t\ttest('0343 15-555-1212', 'AR', '93435551212')\r\n\r\n\t\ttest('+54 9 3715 65 4320', 'AR', '93715654320')\r\n\t\ttest('03715 15 65 4320', 'AR', '93715654320')\r\n\r\n\t\t// Test parsing fixed-line numbers of Argentina.\r\n\t\ttest('+54 11 3797 0000', 'AR', '1137970000')\r\n\t\ttest('011 3797 0000', 'AR', '1137970000')\r\n\r\n\t\ttest('+54 3715 65 4321', 'AR', '3715654321')\r\n\t\ttest('03715 65 4321', 'AR', '3715654321')\r\n\r\n\t\ttest('+54 23 1234 0000', 'AR', '2312340000')\r\n\t\ttest('023 1234 0000', 'AR', '2312340000')\r\n\t})\r\n\r\n\tit('should only support the supported leniency values', function() {\r\n\t\texpect(() => new PhoneNumberMatcher('+54 23 1234 0000', { leniency: 'STRICT_GROUPING', v2: true }, metadata)).to.throw('Supported values: \"POSSIBLE\", \"VALID\".')\r\n\t})\r\n\r\n\tit('should validate input parameters', function() {\r\n\t\t// expect(() => new PhoneNumberMatcher('+54 23 1234 0000', { v2: true }, metadata)).to.throw('`leniency` is required')\r\n\t\texpect(() => new PhoneNumberMatcher('+54 23 1234 0000', { leniency: '???', v2: true }, metadata)).to.throw('Unknown leniency: \"???\"')\r\n\t\texpect(() => new PhoneNumberMatcher('+54 23 1234 0000', { maxTries: -1, v2: true }, metadata)).to.throw('`maxTries` must be `>= 0`')\r\n\t})\r\n\r\n\tit('should throw when calling `.next()` and there\\'s no next match', function() {\r\n\t\tconst matcher = new PhoneNumberMatcher('+54 23 1234 0000', { v2: true }, metadata)\r\n\t\tmatcher.next()\r\n\t\texpect(() => matcher.next()).to.throw('No next element')\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAiE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAEjE,SAASE,IAAIA,CAACC,IAAI,EAAEC,cAAc,EAAEC,eAAe,EAAE;EACpD,IAAI,OAAOA,eAAe,KAAK,QAAQ,EAAE;IACxCA,eAAe,GAAG,CAAC;MAClBC,cAAc,EAAED;IACjB,CAAC,CAAC;EACH;EACA,IAAME,OAAO,GAAG,IAAIC,8BAAkB,CAACL,IAAI,EAAE;IAAEC,cAAc,EAAdA,cAAc;IAAEK,EAAE,EAAE;EAAK,CAAC,EAAEC,uBAAQ,CAAC;EACpF,OAAOH,OAAO,CAACI,OAAO,CAAC,CAAC,EAAE;IACzB,IAAMC,MAAM,GAAGL,OAAO,CAACM,IAAI,CAAC,CAAC;IAC7B,IAAMC,WAAW,GAAGT,eAAe,CAACU,KAAK,CAAC,CAAC;IAC3C,IAAID,WAAW,CAACE,QAAQ,KAAKC,SAAS,EAAE;MACvCC,MAAM,CAACN,MAAM,CAACI,QAAQ,CAAC,CAACG,EAAE,CAACC,KAAK,CAACN,WAAW,CAACE,QAAQ,CAAC;IACvD;IACA,IAAIF,WAAW,CAACO,MAAM,KAAKJ,SAAS,EAAE;MACrCC,MAAM,CAACN,MAAM,CAACS,MAAM,CAAC,CAACF,EAAE,CAACC,KAAK,CAACN,WAAW,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BAAkB,CAAC,kBAAkB,EAAE;MAAEC,EAAE,EAAE;IAAK,CAAC,EAAEC,uBAAQ,CAAC;IAClFH,OAAO,CAACM,IAAI,CAAC,CAAC;IACdK,MAAM,CAAC;MAAA,OAAMX,OAAO,CAACM,IAAI,CAAC,CAAC;IAAA,EAAC,CAACM,EAAE,SAAM,CAAC,iBAAiB,CAAC;EACzD,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PhoneNumberMatcher.test.js","names":["_PhoneNumberMatcher","_interopRequireDefault","require","_metadataMin","e","__esModule","test","text","defaultCountry","expectedNumbers","nationalNumber","matcher","PhoneNumberMatcher","v2","metadata","hasNext","number","next","phoneNumber","shift","startsAt","undefined","expect","to","equal","endsAt","country","length","describe","it","leniency","maxTries","number1","number2"],"sources":["../source/PhoneNumberMatcher.test.js"],"sourcesContent":["import PhoneNumberMatcher from './PhoneNumberMatcher.js'\r\nimport metadata from '../metadata.min.json' with { type: 'json' }\r\n\r\nfunction test(text, defaultCountry, expectedNumbers) {\r\n\tif (typeof expectedNumbers === 'string') {\r\n\t\texpectedNumbers = [{\r\n\t\t\tnationalNumber: expectedNumbers\r\n\t\t}]\r\n\t}\r\n\tconst matcher = new PhoneNumberMatcher(text, { defaultCountry, v2: true }, metadata)\r\n\twhile (matcher.hasNext()) {\r\n\t\tconst number = matcher.next()\r\n\t\tconst phoneNumber = expectedNumbers.shift()\r\n\t\tif (phoneNumber.startsAt !== undefined) {\r\n\t\t\texpect(number.startsAt).to.equal(phoneNumber.startsAt)\r\n\t\t}\r\n\t\tif (phoneNumber.endsAt !== undefined) {\r\n\t\t\texpect(number.endsAt).to.equal(phoneNumber.endsAt)\r\n\t\t}\r\n\t\texpect(number.number.country).to.equal(phoneNumber.country || defaultCountry)\r\n\t\texpect(number.number.nationalNumber).to.equal(phoneNumber.nationalNumber)\r\n\t}\r\n\texpect(expectedNumbers.length).to.equal(0)\r\n}\r\n\r\ndescribe('PhoneNumberMatcher', () => {\r\n\tit('should find phone numbers', () => {\r\n\t\ttest(\r\n\t\t\t'The number is +7 (800) 555-35-35 and not (213) 373-4253 as written in the document.',\r\n\t\t\t'US',\r\n\t\t\t[{\r\n\t\t\t\tcountry: 'RU',\r\n\t\t\t\tnationalNumber: '8005553535',\r\n\t\t\t\tstartsAt: 14,\r\n\t\t\t\tendsAt: 32\r\n\t\t\t}, {\r\n\t\t\t\tcountry: 'US',\r\n\t\t\t\tnationalNumber: '2133734253',\r\n\t\t\t\tstartsAt: 41,\r\n\t\t\t\tendsAt: 55\r\n\t\t\t}]\r\n\t\t)\r\n\t})\r\n\r\n\tit('should find phone numbers from Mexico', () => {\r\n\t\t// Test parsing fixed-line numbers of Mexico.\r\n\t\ttest('+52 (449)978-0001', 'MX', '4499780001')\r\n\t\ttest('01 (449)978-0001', 'MX', '4499780001')\r\n\t\ttest('(449)978-0001', 'MX', '4499780001')\r\n\r\n\t\t// \"Dialling tokens 01, 02, 044, 045 and 1 are removed as they are\r\n\t\t// no longer valid since August 2019.\"\r\n\t\t// // Test parsing mobile numbers of Mexico.\r\n\t\t// test('+52 1 33 1234-5678', 'MX', '3312345678')\r\n\t\t// test('044 (33) 1234-5678', 'MX', '3312345678')\r\n\t\t// test('045 33 1234-5678', 'MX', '3312345678')\r\n\t})\r\n\r\n\tit('should find phone numbers from Argentina', () => {\r\n\t\t// Test parsing mobile numbers of Argentina.\r\n\t\ttest('+54 9 343 555 1212', 'AR', '93435551212')\r\n\t\ttest('0343 15-555-1212', 'AR', '93435551212')\r\n\r\n\t\ttest('+54 9 3715 65 4320', 'AR', '93715654320')\r\n\t\ttest('03715 15 65 4320', 'AR', '93715654320')\r\n\r\n\t\t// Test parsing fixed-line numbers of Argentina.\r\n\t\ttest('+54 11 3797 0000', 'AR', '1137970000')\r\n\t\ttest('011 3797 0000', 'AR', '1137970000')\r\n\r\n\t\ttest('+54 3715 65 4321', 'AR', '3715654321')\r\n\t\ttest('03715 65 4321', 'AR', '3715654321')\r\n\r\n\t\ttest('+54 23 1234 0000', 'AR', '2312340000')\r\n\t\ttest('023 1234 0000', 'AR', '2312340000')\r\n\t})\r\n\r\n\tit('should only support the supported leniency values', function() {\r\n\t\texpect(() => new PhoneNumberMatcher('+54 23 1234 0000', { leniency: 'STRICT_GROUPING', v2: true }, metadata)).to.throw('Supported values: \"POSSIBLE\", \"VALID\".')\r\n\t})\r\n\r\n\tit('should validate input parameters', function() {\r\n\t\t// expect(() => new PhoneNumberMatcher('+54 23 1234 0000', { v2: true }, metadata)).to.throw('`leniency` is required')\r\n\t\texpect(() => new PhoneNumberMatcher('+54 23 1234 0000', { leniency: '???', v2: true }, metadata)).to.throw('Unknown leniency: \"???\"')\r\n\t\texpect(() => new PhoneNumberMatcher('+54 23 1234 0000', { maxTries: -1, v2: true }, metadata)).to.throw('`maxTries` must be `>= 0`')\r\n\t})\r\n\r\n\tit('should throw when calling `.next()` and there\\'s no next match', function() {\r\n\t\tconst matcher = new PhoneNumberMatcher('+54 23 1234 0000', { v2: true }, metadata)\r\n\t\tmatcher.next()\r\n\t\texpect(() => matcher.next()).to.throw('No next element')\r\n\t})\r\n\r\n\tit('should find phone numbers that are separated by a slash', function() {\r\n\t\tconst matcher = new PhoneNumberMatcher('651-234-2345/332-445-1234', { defaultCountry: 'US', v2: true }, metadata)\r\n\r\n\t\texpect(matcher.hasNext()).to.equal(true)\r\n\t\tconst number1 = matcher.next()\r\n\t\texpect(number1.startsAt).to.equal(0)\r\n\t\texpect(number1.number.number).to.equal('+16512342345')\r\n\r\n\t\texpect(matcher.hasNext()).to.equal(true)\r\n\t\tconst number2 = matcher.next()\r\n\t\texpect(number2.startsAt).to.equal(13)\r\n\t\texpect(number2.number.number).to.equal('+13324451234')\r\n\r\n\t\texpect(matcher.hasNext()).to.equal(false)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;A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