libphonenumber-js 1.9.22 → 1.9.26
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 +16 -0
- package/README.md +104 -5
- package/build/AsYouType.test.js +8 -7
- package/build/AsYouType.test.js.map +1 -1
- package/build/helpers/isViablePhoneNumber.js +22 -1
- package/build/helpers/isViablePhoneNumber.js.map +1 -1
- package/build/parse.test.js +3 -3
- package/build/parse.test.js.map +1 -1
- package/build/parsePhoneNumber.test.js +14 -4
- package/build/parsePhoneNumber.test.js.map +1 -1
- package/build/parse_.js +20 -3
- package/build/parse_.js.map +1 -1
- package/build/validatePhoneNumberLength.js +53 -0
- package/build/validatePhoneNumberLength.js.map +1 -0
- package/build/validatePhoneNumberLength.test.js +37 -0
- package/build/validatePhoneNumberLength.test.js.map +1 -0
- 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/core/index.commonjs.js +1 -0
- package/core/index.d.ts +7 -2
- package/core/index.js +1 -0
- package/es6/AsYouType.test.js +8 -7
- package/es6/AsYouType.test.js.map +1 -1
- package/es6/helpers/isViablePhoneNumber.js +20 -1
- package/es6/helpers/isViablePhoneNumber.js.map +1 -1
- package/es6/parse.test.js +3 -3
- package/es6/parse.test.js.map +1 -1
- package/es6/parsePhoneNumber.test.js +14 -4
- package/es6/parsePhoneNumber.test.js.map +1 -1
- package/es6/parse_.js +18 -3
- package/es6/parse_.js.map +1 -1
- package/es6/validatePhoneNumberLength.js +39 -0
- package/es6/validatePhoneNumberLength.js.map +1 -0
- package/es6/validatePhoneNumberLength.test.js +32 -0
- package/es6/validatePhoneNumberLength.test.js.map +1 -0
- package/index.common.js +4 -0
- package/index.d.ts +5 -2
- package/index.es6.js +1 -0
- package/max/exports/validatePhoneNumberLength.js +6 -0
- package/max/index.commonjs.js +4 -0
- package/max/index.js +1 -0
- package/metadata.full.json +1 -1
- package/metadata.full.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.js +1 -1
- package/min/exports/validatePhoneNumberLength.js +6 -0
- package/min/index.commonjs.js +4 -0
- package/min/index.d.ts +5 -2
- package/min/index.js +1 -0
- package/mobile/exports/validatePhoneNumberLength.js +6 -0
- package/mobile/index.commonjs.js +4 -0
- package/mobile/index.js +1 -0
- package/package.json +1 -1
- package/source/AsYouType.test.js +8 -6
- package/source/helpers/isViablePhoneNumber.js +29 -0
- package/source/parse.test.js +3 -3
- package/source/parsePhoneNumber.test.js +5 -3
- package/source/parse_.js +12 -3
- package/source/validatePhoneNumberLength.js +31 -0
- package/source/validatePhoneNumberLength.test.js +30 -0
- package/types.d.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/helpers/isViablePhoneNumber.js"],"names":["MIN_LENGTH_FOR_NSN","VALID_DIGITS","VALID_PUNCTUATION","PLUS_CHARS","createExtensionPattern","MIN_LENGTH_PHONE_NUMBER_PATTERN","VALID_PHONE_NUMBER","
|
|
1
|
+
{"version":3,"sources":["../../source/helpers/isViablePhoneNumber.js"],"names":["MIN_LENGTH_FOR_NSN","VALID_DIGITS","VALID_PUNCTUATION","PLUS_CHARS","createExtensionPattern","MIN_LENGTH_PHONE_NUMBER_PATTERN","VALID_PHONE_NUMBER","VALID_PHONE_NUMBER_START_REG_EXP","RegExp","VALID_PHONE_NUMBER_WITH_EXTENSION","VALID_PHONE_NUMBER_PATTERN","isViablePhoneNumber","number","length","test","isViablePhoneNumberStart"],"mappings":"AAAA,SACCA,kBADD,EAECC,YAFD,EAGCC,iBAHD,EAICC,UAJD,QAKO,cALP;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O,SAASG,wBAAT,CAAkCH,MAAlC,EAA0C;AAChD,SAAOL,gCAAgC,CAACO,IAAjC,CAAsCF,MAAtC,CAAP;AACA","sourcesContent":["import {\r\n\tMIN_LENGTH_FOR_NSN,\r\n\tVALID_DIGITS,\r\n\tVALID_PUNCTUATION,\r\n\tPLUS_CHARS\r\n} from '../constants'\r\n\r\nimport createExtensionPattern from './extension/createExtensionPattern'\r\n\r\n// Regular expression of viable phone numbers. This is location independent.\r\n// Checks we have at least three leading digits, and only valid punctuation,\r\n// alpha characters and digits in the phone number. Does not include extension\r\n// data. The symbol 'x' is allowed here as valid punctuation since it is often\r\n// used as a placeholder for carrier codes, for example in Brazilian phone\r\n// numbers. We also allow multiple '+' characters at the start.\r\n//\r\n// Corresponds to the following:\r\n// [digits]{minLengthNsn}|\r\n// plus_sign*\r\n// (([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*\r\n//\r\n// The first reg-ex is to allow short numbers (two digits long) to be parsed if\r\n// they are entered as \"15\" etc, but only if there is no punctuation in them.\r\n// The second expression restricts the number of digits to three or more, but\r\n// then allows them to be in international form, and to have alpha-characters\r\n// and punctuation. We split up the two reg-exes here and combine them when\r\n// creating the reg-ex VALID_PHONE_NUMBER_PATTERN itself so we can prefix it\r\n// with ^ and append $ to each branch.\r\n//\r\n// \"Note VALID_PUNCTUATION starts with a -,\r\n// so must be the first in the range\" (c) Google devs.\r\n// (wtf did they mean by saying that; probably nothing)\r\n//\r\nconst MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'\r\n//\r\n// And this is the second reg-exp:\r\n// (see MIN_LENGTH_PHONE_NUMBER_PATTERN for a full description of this reg-exp)\r\n//\r\nexport const VALID_PHONE_NUMBER =\r\n\t'[' + PLUS_CHARS + ']{0,1}' +\r\n\t'(?:' +\r\n\t\t'[' + VALID_PUNCTUATION + ']*' +\r\n\t\t'[' + VALID_DIGITS + ']' +\r\n\t'){3,}' +\r\n\t'[' +\r\n\t\tVALID_PUNCTUATION +\r\n\t\tVALID_DIGITS +\r\n\t']*'\r\n\r\n// This regular expression isn't present in Google's `libphonenumber`\r\n// and is only used to determine whether the phone number being input\r\n// is too short for it to even consider it a \"valid\" number.\r\n// This is just a way to differentiate between a really invalid phone\r\n// number like \"abcde\" and a valid phone number that a user has just\r\n// started inputting, like \"+1\" or \"1\": both these cases would be\r\n// considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this\r\n// library can provide a more detailed error message — whether it's\r\n// really \"not a number\", or is it just a start of a valid phone number.\r\nconst VALID_PHONE_NUMBER_START_REG_EXP = new RegExp(\r\n\t'^' +\r\n\t'[' + PLUS_CHARS + ']{0,1}' +\r\n\t'(?:' +\r\n\t\t'[' + VALID_PUNCTUATION + ']*' +\r\n\t\t'[' + VALID_DIGITS + ']' +\r\n\t'){1,2}' +\r\n\t'$'\r\n, 'i')\r\n\r\nexport const VALID_PHONE_NUMBER_WITH_EXTENSION =\r\n\tVALID_PHONE_NUMBER +\r\n\t// Phone number extensions\r\n\t'(?:' + createExtensionPattern() + ')?'\r\n\r\n// The combined regular expression for valid phone numbers:\r\n//\r\nconst VALID_PHONE_NUMBER_PATTERN = new RegExp(\r\n\t// Either a short two-digit-only phone number\r\n\t'^' +\r\n\t\tMIN_LENGTH_PHONE_NUMBER_PATTERN +\r\n\t'$' +\r\n\t'|' +\r\n\t// Or a longer fully parsed phone number (min 3 characters)\r\n\t'^' +\r\n\t\tVALID_PHONE_NUMBER_WITH_EXTENSION +\r\n\t'$'\r\n, 'i')\r\n\r\n// Checks to see if the string of characters could possibly be a phone number at\r\n// all. At the moment, checks to see that the string begins with at least 2\r\n// digits, ignoring any punctuation commonly found in phone numbers. This method\r\n// does not require the number to be normalized in advance - but does assume\r\n// that leading non-number symbols have been removed, such as by the method\r\n// `extract_possible_number`.\r\n//\r\nexport default function isViablePhoneNumber(number) {\r\n\treturn number.length >= MIN_LENGTH_FOR_NSN &&\r\n\t\tVALID_PHONE_NUMBER_PATTERN.test(number)\r\n}\r\n\r\n// This is just a way to differentiate between a really invalid phone\r\n// number like \"abcde\" and a valid phone number that a user has just\r\n// started inputting, like \"+1\" or \"1\": both these cases would be\r\n// considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this\r\n// library can provide a more detailed error message — whether it's\r\n// really \"not a number\", or is it just a start of a valid phone number.\r\nexport function isViablePhoneNumberStart(number) {\r\n\treturn VALID_PHONE_NUMBER_START_REG_EXP.test(number)\r\n}"],"file":"isViablePhoneNumber.js"}
|
package/es6/parse.test.js
CHANGED
|
@@ -155,12 +155,12 @@ describe('parse', function () {
|
|
|
155
155
|
possible: false
|
|
156
156
|
}); // Too long.
|
|
157
157
|
|
|
158
|
-
parseNumber('+
|
|
158
|
+
parseNumber('+1 213 37342530', {
|
|
159
159
|
extended: true
|
|
160
160
|
}).should.deep.equal({
|
|
161
161
|
country: undefined,
|
|
162
|
-
countryCallingCode: '
|
|
163
|
-
phone: '
|
|
162
|
+
countryCallingCode: '1',
|
|
163
|
+
phone: '21337342530',
|
|
164
164
|
carrierCode: undefined,
|
|
165
165
|
ext: undefined,
|
|
166
166
|
valid: false,
|
package/es6/parse.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/parse.test.js"],"names":["metadata","_parseNumber","Metadata","parseNumber","parameters","push","apply","USE_NON_GEOGRAPHIC_COUNTRY_CODE","describe","it","should","deep","equal","defaultCountry","country","phone","extended","countryCallingCode","carrierCode","undefined","ext","valid","possible","thrower","defaultCallingCode","expect","to","be","v2"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,sBAArB;AACA,OAAOC,YAAP,MAAyB,SAAzB;AACA,OAAOC,QAAP,MAAqB,YAArB;;AAEA,SAASC,WAAT,GAAoC;AAAA,oCAAZC,UAAY;AAAZA,IAAAA,UAAY;AAAA;;AACnCA,EAAAA,UAAU,CAACC,IAAX,CAAgBL,QAAhB;AACA,SAAOC,YAAY,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'\r\n\r\nfunction parseNumber(...parameters) {\r\n\tparameters.push(metadata)\r\n\treturn _parseNumber.apply(this, parameters)\r\n}\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\ndescribe('parse', () => {\r\n\tit('should not parse invalid phone numbers', () => {\r\n\t\t// Too short.\r\n\t\tparseNumber('+7 (800) 55-35-35').should.deep.equal({})\r\n\t\t// Too long.\r\n\t\tparseNumber('+7 (800) 55-35-35-55').should.deep.equal({})\r\n\r\n\t\tparseNumber('+7 (800) 55-35-35', 'US').should.deep.equal({})\r\n\t\tparseNumber('(800) 55 35 35', { defaultCountry: 'RU' }).should.deep.equal({})\r\n\t\tparseNumber('+1 187 215 5230', 'US').should.deep.equal({})\r\n\r\n\t\tparseNumber('911231231', 'BE').should.deep.equal({})\r\n\t})\r\n\r\n\tit('should parse valid phone numbers', () => {\r\n\t\t// Instant loans\r\n\t\t// https://www.youtube.com/watch?v=6e1pMrYH5jI\r\n\t\t//\r\n\t\t// Restrict to RU\r\n\t\tparseNumber('Phone: 8 (800) 555 35 35.', 'RU').should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\t\t// International format\r\n\t\tparseNumber('Phone: +7 (800) 555-35-35.').should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\t\t// // Restrict to US, but not a US country phone code supplied\r\n\t\t// parseNumber('+7 (800) 555-35-35', 'US').should.deep.equal({})\r\n\t\t// Restrict to RU\r\n\t\tparseNumber('(800) 555 35 35', 'RU').should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\t\t// Default to RU\r\n\t\tparseNumber('8 (800) 555 35 35', { defaultCountry: 'RU' }).should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\r\n\t\t// Gangster partyline\r\n\t\tparseNumber('+1-213-373-4253').should.deep.equal({ country: 'US', phone: '2133734253' })\r\n\r\n\t\t// Switzerland (just in case)\r\n\t\tparseNumber('044 668 18 00', 'CH').should.deep.equal({ country: 'CH', phone: '446681800' })\r\n\r\n\t\t// China, Beijing\r\n\t\tparseNumber('010-852644821', 'CN').should.deep.equal({ country: 'CN', phone: '10852644821' })\r\n\r\n\t\t// France\r\n\t\tparseNumber('+33169454850').should.deep.equal({ country: 'FR', phone: '169454850' })\r\n\r\n\t\t// UK (Jersey)\r\n\t\tparseNumber('+44 7700 300000').should.deep.equal({ country: 'JE', phone: '7700300000' })\r\n\r\n\t\t// KZ\r\n\t\tparseNumber('+7 702 211 1111').should.deep.equal({ country: 'KZ', phone: '7022111111' })\r\n\r\n\t\t// Brazil\r\n\t\tparseNumber('11987654321', 'BR').should.deep.equal({ country: 'BR', phone: '11987654321' })\r\n\r\n\t\t// Long country phone code.\r\n\t\tparseNumber('+212659777777').should.deep.equal({ country: 'MA', phone: '659777777' })\r\n\r\n\t\t// No country could be derived.\r\n\t\t// parseNumber('+212569887076').should.deep.equal({ countryPhoneCode: '212', phone: '569887076' })\r\n\r\n\t\t// GB. Moible numbers starting 07624* are Isle of Man.\r\n\t\tparseNumber('07624369230', 'GB').should.deep.equal({ country: 'IM', phone: '7624369230' })\r\n\t})\r\n\r\n\tit('should parse possible numbers', () => {\r\n\t\t// Invalid phone number for a given country.\r\n\t\tparseNumber('1112223344', 'RU', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '1112223344',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// International phone number.\r\n\t\t// Several countries with the same country phone code.\r\n\t\tparseNumber('+71112223344').should.deep.equal({})\r\n\t\tparseNumber('+71112223344', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : undefined,\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '1112223344',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// International phone number.\r\n\t\t// Single country with the given country phone code.\r\n\t\tparseNumber('+33011222333', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'FR',\r\n\t\t\tcountryCallingCode : '33',\r\n\t\t\tphone : '011222333',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// Too short.\r\n\t\t// Won't strip national prefix `8` because otherwise the number would be too short.\r\n\t\tparseNumber('+7 (800) 55-35-35', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '800553535',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : false\r\n\t\t})\r\n\r\n\t\t// Too long.\r\n\t\tparseNumber('+7 (800) 55-35-35-555', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : undefined,\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '00553535555',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : false\r\n\t\t})\r\n\r\n\t\t// No national number to be parsed.\r\n\t\tparseNumber('+996', { extended: true }).should.deep.equal({\r\n\t\t\t// countryCallingCode : '996'\r\n\t\t})\r\n\r\n\t\t// Valid number.\r\n\t\tparseNumber('+78005553535', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '8005553535',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : true,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/211\r\n\t\tparseNumber('+966', { extended: true }).should.deep.equal({})\r\n\t\tparseNumber('+9664', { extended: true }).should.deep.equal({})\r\n\t\tparseNumber('+96645', { extended: true }).should.deep.equal({\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\tphone : '45',\r\n\t\t\text : undefined,\r\n\t\t\tcountry : 'SA',\r\n\t\t\tcountryCallingCode : '966',\r\n\t\t\tpossible : false,\r\n\t\t\tvalid : false\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse non-European digits', () => {\r\n\t\tparseNumber('+١٢١٢٢٣٢٣٢٣٢').should.deep.equal({ country: 'US', phone: '2122323232' })\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\tlet thrower\r\n\r\n\t\t// No input\r\n\t\tparseNumber('').should.deep.equal({})\r\n\r\n\t\t// No country phone code\r\n\t\tparseNumber('+').should.deep.equal({})\r\n\r\n\t\t// No country at all (non international number and no explicit country code)\r\n\t\tparseNumber('123').should.deep.equal({})\r\n\r\n\t\t// No country metadata for this `require` country code\r\n\t\tthrower = () => parseNumber('123', 'ZZ')\r\n\t\tthrower.should.throw('Unknown country')\r\n\r\n\t\t// No country metadata for this `default` country code\r\n\t\tthrower = () => parseNumber('123', { defaultCountry: 'ZZ' })\r\n\t\tthrower.should.throw('Unknown country')\r\n\r\n\t\t// Invalid country phone code\r\n\t\tparseNumber('+210').should.deep.equal({})\r\n\r\n\t\t// Invalid country phone code (extended parsing mode)\r\n\t\tparseNumber('+210', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Too short of a number.\r\n\t\tparseNumber('1', 'US', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Too long of a number.\r\n\t\tparseNumber('1111111111111111111', 'RU', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Not a number.\r\n\t\tparseNumber('abcdefg', 'US', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Country phone code beginning with a '0'\r\n\t\tparseNumber('+0123').should.deep.equal({})\r\n\r\n\t\t// Barbados NANPA phone number\r\n\t\tparseNumber('+12460000000').should.deep.equal({ country: 'BB', phone: '2460000000' })\r\n\r\n\t\t// // A case when country (restricted to) is not equal\r\n\t\t// // to the one parsed out of an international number.\r\n\t\t// parseNumber('+1-213-373-4253', 'RU').should.deep.equal({})\r\n\r\n\t\t// National (significant) number too short\r\n\t\tparseNumber('2', 'US').should.deep.equal({})\r\n\r\n\t\t// National (significant) number too long\r\n\t\tparseNumber('222222222222222222', 'US').should.deep.equal({})\r\n\r\n\t\t// No `national_prefix_for_parsing`\r\n\t\tparseNumber('41111', 'AC').should.deep.equal({ country: 'AC', phone: '41111'})\r\n\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/235\r\n\t\t// `matchesEntirely()` bug fix.\r\n\t\tparseNumber('+4915784846111').should.deep.equal({ country: 'DE', phone: '15784846111' })\r\n\r\n\t\t// No metadata\r\n\t\tthrower = () => _parseNumber('')\r\n\t\tthrower.should.throw('`metadata` argument not passed')\r\n\r\n\t\t// Numerical `value`\r\n\t\tthrower = () => parseNumber(2141111111, 'US')\r\n\t\tthrower.should.throw('A text for parsing must be a string.')\r\n\r\n\t\t// Input string too long.\r\n\t\tparseNumber('8005553535 ', 'RU').should.deep.equal({})\r\n\t})\r\n\r\n\tit('should parse phone number extensions', () => {\r\n\t\t// \"ext\"\r\n\t\tparseNumber('2134567890 ext 123', 'US').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890',\r\n\t\t\text : '123'\r\n\t\t})\r\n\r\n\t\t// \"ext.\"\r\n\t\tparseNumber('+12134567890 ext. 12345', 'US').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890',\r\n\t\t\text : '12345'\r\n\t\t})\r\n\r\n\t\t// \"доб.\"\r\n\t\tparseNumber('+78005553535 доб. 1234', 'RU').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '1234'\r\n\t\t})\r\n\r\n\t\t// \"#\"\r\n\t\tparseNumber('+12134567890#1234').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890',\r\n\t\t\text : '1234'\r\n\t\t})\r\n\r\n\t\t// \"x\"\r\n\t\tparseNumber('+78005553535 x1234').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '1234'\r\n\t\t})\r\n\r\n\t\t// Not a valid extension\r\n\t\tparseNumber('2134567890 ext. abc', 'US').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse RFC 3966 phone numbers', () => {\r\n\t\tparseNumber('tel:+78005553535;ext=123').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '123'\r\n\t\t})\r\n\r\n\t\t// Should parse \"visual separators\".\r\n\t\tparseNumber('tel:+7(800)555-35.35;ext=123').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '123'\r\n\t\t})\r\n\r\n\t\t// Invalid number.\r\n\t\tparseNumber('tel:+7x8005553535;ext=123').should.deep.equal({})\r\n\t})\r\n\r\n\tit('should parse invalid international numbers even if they are invalid', () => {\r\n\t\tparseNumber('+7(8)8005553535', 'RU').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse carrier codes', () => {\r\n\t\tparseNumber('0 15 21 5555-5555', 'BR', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'BR',\r\n\t\t\tcountryCallingCode : '55',\r\n\t\t\tphone : '2155555555',\r\n\t\t\tcarrierCode : '15',\r\n\t\t\text : undefined,\r\n\t\t\tvalid : true,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse IDD prefixes', () => {\r\n\t\tparseNumber('011 61 2 3456 7890', 'US').should.deep.equal({\r\n\t\t\tphone : '234567890',\r\n\t\t\tcountry : 'AU'\r\n\t\t})\r\n\r\n\t\tparseNumber('011 61 2 3456 7890', 'FR').should.deep.equal({})\r\n\r\n\t\tparseNumber('00 61 2 3456 7890', 'US').should.deep.equal({})\r\n\r\n\t\tparseNumber('810 61 2 3456 7890', 'RU').should.deep.equal({\r\n\t\t\tphone : '234567890',\r\n\t\t\tcountry : 'AU'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should work with v2 API', () => {\r\n\t\tparseNumber('+99989160151539')\r\n\t})\r\n\r\n\tit('should work with Argentina numbers', () => {\r\n\t\t// The same mobile number is written differently\r\n\t\t// in different formats in Argentina:\r\n\t\t// `9` gets prepended in international format.\r\n\t\tparseNumber('+54 9 3435 55 1212').should.deep.equal({\r\n\t\t\tcountry: 'AR',\r\n\t\t\tphone: '93435551212'\r\n\t\t})\r\n\t\tparseNumber('0343 15-555-1212', 'AR').should.deep.equal({\r\n\t\t\tcountry: 'AR',\r\n\t\t\tphone: '93435551212'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should work with Mexico numbers', () => {\r\n\t\t// Fixed line.\r\n\t\tparseNumber('+52 449 978 0001').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '4499780001'\r\n\t\t})\r\n\t\tparseNumber('01 (449)978-0001', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '4499780001'\r\n\t\t})\r\n\t\tparseNumber('(449)978-0001', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '4499780001'\r\n\t\t})\r\n\t\t// Mobile.\r\n\t\t// `1` is prepended before area code to mobile numbers in international format.\r\n\t\tparseNumber('+52 1 33 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t\tparseNumber('+52 33 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t\tparseNumber('044 (33) 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t\tparseNumber('045 33 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers', () => {\r\n\t\tparseNumber('+870773111632').should.deep.equal(\r\n\t\t\tUSE_NON_GEOGRAPHIC_COUNTRY_CODE ?\r\n\t\t\t{\r\n\t\t\t\tcountry: '001',\r\n\t\t\t\tphone: '773111632'\r\n\t\t\t} :\r\n\t\t\t{}\r\n\t\t)\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (default country code)', () => {\r\n\t\tparseNumber('773111632', { defaultCallingCode: '870' }).should.deep.equal(\r\n\t\t\tUSE_NON_GEOGRAPHIC_COUNTRY_CODE ?\r\n\t\t\t{\r\n\t\t\t\tcountry: '001',\r\n\t\t\t\tphone: '773111632'\r\n\t\t\t} :\r\n\t\t\t{}\r\n\t\t)\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (extended)', () => {\r\n\t\tparseNumber('+870773111632', { extended: true }).should.deep.equal({\r\n\t\t\tcountry: USE_NON_GEOGRAPHIC_COUNTRY_CODE ? '001' : undefined,\r\n\t\t\tcountryCallingCode: '870',\r\n\t\t\tphone: '773111632',\r\n\t\t\tcarrierCode: undefined,\r\n\t\t\text: undefined,\r\n\t\t\tpossible: true,\r\n\t\t\tvalid: true\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (default country code) (extended)', () => {\r\n\t\tparseNumber('773111632', { defaultCallingCode: '870', extended: true }).should.deep.equal({\r\n\t\t\tcountry: USE_NON_GEOGRAPHIC_COUNTRY_CODE ? '001' : undefined,\r\n\t\t\tcountryCallingCode: '870',\r\n\t\t\tphone: '773111632',\r\n\t\t\tcarrierCode: undefined,\r\n\t\t\text: undefined,\r\n\t\t\tpossible: true,\r\n\t\t\tvalid: true\r\n\t\t})\r\n\t})\r\n\r\n\tit('shouldn\\'t crash when invalid `defaultCallingCode` is passed', () => {\r\n\t\texpect(() => parseNumber('773111632', { defaultCallingCode: '999' }))\r\n\t\t\t.to.throw('Unknown calling code')\r\n\t})\r\n\r\n\tit('shouldn\\'t set `country` when there\\'s no `defaultCountry` and `defaultCallingCode` is not of a \"non-geographic entity\"', () => {\r\n\t\tparseNumber('88005553535', { defaultCallingCode: '7' }).should.deep.equal({\r\n\t\t\tcountry: 'RU',\r\n\t\t\tphone: '8005553535'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should correctly parse numbers starting with the same digit as the national prefix', () => {\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/373\r\n\t\t// `BY`'s `national_prefix` is `8`.\r\n\t\tparseNumber('+37582004910060').should.deep.equal({\r\n\t\t\tcountry: 'BY',\r\n\t\t\tphone: '82004910060'\r\n\t\t});\r\n\t})\r\n\r\n\tit('should autocorrect numbers without a leading +', () => {\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/376\r\n\t\tparseNumber('375447521111', 'BY').should.deep.equal({\r\n\t\t\tcountry: 'BY',\r\n\t\t\tphone: '447521111'\r\n\t\t});\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/316\r\n\t\tparseNumber('33612902554', 'FR').should.deep.equal({\r\n\t\t\tcountry: 'FR',\r\n\t\t\tphone: '612902554'\r\n\t\t});\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/375\r\n\t\tparseNumber('61438331999', 'AU').should.deep.equal({\r\n\t\t\tcountry: 'AU',\r\n\t\t\tphone: '438331999'\r\n\t\t});\r\n\t\t// A case when `49` is a country calling code of a number without a leading `+`.\r\n\t\tparseNumber('4930123456', 'DE').should.deep.equal({\r\n\t\t\tcountry: 'DE',\r\n\t\t\tphone: '30123456'\r\n\t\t});\r\n\t\t// A case when `49` is a valid area code.\r\n\t\tparseNumber('4951234567890', 'DE').should.deep.equal({\r\n\t\t\tcountry: 'DE',\r\n\t\t\tphone: '4951234567890'\r\n\t\t});\r\n\t})\r\n\r\n\tit('should parse extensions (long extensions with explicitl abels)', () => {\r\n\t\t// Test lower and upper limits of extension lengths for each type of label.\r\n\r\n\t\t// Firstly, when in RFC format: PhoneNumberUtil.extLimitAfterExplicitLabel\r\n\t\tparseNumber('33316005 ext 0', 'NZ').ext.should.equal('0')\r\n\t\tparseNumber('33316005 ext 01234567890123456789', 'NZ').ext.should.equal('01234567890123456789')\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('33316005 ext 012345678901234567890', 'NZ').ext).to.be.undefined\r\n\r\n\t\t// Explicit extension label.\r\n\t\tparseNumber('03 3316005ext:1', 'NZ').ext.should.equal('1')\r\n\t\tparseNumber('03 3316005 xtn:12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 extension\\t12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 xtensio:12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 xtensión, 12345678901234567890#', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005extension.12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 доб:12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('03 3316005 extension 123456789012345678901', 'NZ').ext).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse extensions (long extensions with auto dialling labels)', () => {\r\n\t\tparseNumber('+12679000000,,123456789012345#').ext.should.equal('123456789012345')\r\n\t\tparseNumber('+12679000000;123456789012345#').ext.should.equal('123456789012345')\r\n\t\tparseNumber('+442034000000,,123456789#').ext.should.equal('123456789')\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('+12679000000,,1234567890123456#').ext).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse extensions (short extensions with ambiguous characters)', () => {\r\n\t\tparseNumber('03 3316005 x 123456789', 'NZ').ext.should.equal('123456789')\r\n\t\tparseNumber('03 3316005 x. 123456789', 'NZ').ext.should.equal('123456789')\r\n\t\tparseNumber('03 3316005 #123456789#', 'NZ').ext.should.equal('123456789')\r\n\t\tparseNumber('03 3316005 ~ 123456789', 'NZ').ext.should.equal('123456789')\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('03 3316005 ~ 1234567890', 'NZ').ext).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse extensions (short extensions when not sure of label)', () => {\r\n\t\tparseNumber('+1123-456-7890 666666#', { v2: true }).ext.should.equal('666666')\r\n\t\tparseNumber('+11234567890-6#', { v2: true }).ext.should.equal('6')\r\n\t\t// Extension too long.\r\n\t\texpect(() => parseNumber('+1123-456-7890 7777777#', { v2: true })).to.throw('NOT_A_NUMBER')\r\n\t})\r\n})"],"file":"parse.test.js"}
|
|
1
|
+
{"version":3,"sources":["../source/parse.test.js"],"names":["metadata","_parseNumber","Metadata","parseNumber","parameters","push","apply","USE_NON_GEOGRAPHIC_COUNTRY_CODE","describe","it","should","deep","equal","defaultCountry","country","phone","extended","countryCallingCode","carrierCode","undefined","ext","valid","possible","thrower","defaultCallingCode","expect","to","be","v2"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,sBAArB;AACA,OAAOC,YAAP,MAAyB,SAAzB;AACA,OAAOC,QAAP,MAAqB,YAArB;;AAEA,SAASC,WAAT,GAAoC;AAAA,oCAAZC,UAAY;AAAZA,IAAAA,UAAY;AAAA;;AACnCA,EAAAA,UAAU,CAACC,IAAX,CAAgBL,QAAhB;AACA,SAAOC,YAAY,CAACK,KAAb,CAAmB,IAAnB,EAAyBF,UAAzB,CAAP;AACA;;AAED,IAAMG,+BAA+B,GAAG,KAAxC;AAEAC,QAAQ,CAAC,OAAD,EAAU,YAAM;AACvBC,EAAAA,EAAE,CAAC,wCAAD,EAA2C,YAAM;AAClD;AACAN,IAAAA,WAAW,CAAC,mBAAD,CAAX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AT,IAAAA,WAAW,CAAC,wBAAD,EAA2B,IAA3B,CAAX,CAA4CiB,GAA5C,CAAgDV,MAAhD,CAAuDE,KAAvD,CAA6D,WAA7D;AACAT,IAAAA,WAAW,CAAC,wBAAD,EAA2B,IAA3B,CAAX,CAA4CiB,GAA5C,CAAgDV,MAAhD,CAAuDE,KAAvD,CAA6D,WAA7D,EAJgF,CAKhF;;AACAa,IAAAA,MAAM,CAACtB,WAAW,CAAC,yBAAD,EAA4B,IAA5B,CAAX,CAA6CiB,GAA9C,CAAN,CAAyDM,EAAzD,CAA4DC,EAA5D,CAA+DR,SAA/D;AACA,GAPC,CAAF;AASAV,EAAAA,EAAE,CAAC,mEAAD,EAAsE,YAAM;AAC7EN,IAAAA,WAAW,CAAC,wBAAD,EAA2B;AAAEyB,MAAAA,EAAE,EAAE;AAAN,KAA3B,CAAX,CAAoDR,GAApD,CAAwDV,MAAxD,CAA+DE,KAA/D,CAAqE,QAArE;AACAT,IAAAA,WAAW,CAAC,iBAAD,EAAoB;AAAEyB,MAAAA,EAAE,EAAE;AAAN,KAApB,CAAX,CAA6CR,GAA7C,CAAiDV,MAAjD,CAAwDE,KAAxD,CAA8D,GAA9D,EAF6E,CAG7E;;AACAa,IAAAA,MAAM,CAAC;AAAA,aAAMtB,WAAW,CAAC,yBAAD,EAA4B;AAAEyB,QAAAA,EAAE,EAAE;AAAN,OAA5B,CAAjB;AAAA,KAAD,CAAN,CAAmEF,EAAnE,UAA4E,cAA5E;AACA,GALC,CAAF;AAMA,CAhgBO,CAAR","sourcesContent":["import metadata from '../metadata.min.json'\r\nimport _parseNumber from './parse'\r\nimport Metadata from './metadata'\r\n\r\nfunction parseNumber(...parameters) {\r\n\tparameters.push(metadata)\r\n\treturn _parseNumber.apply(this, parameters)\r\n}\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\ndescribe('parse', () => {\r\n\tit('should not parse invalid phone numbers', () => {\r\n\t\t// Too short.\r\n\t\tparseNumber('+7 (800) 55-35-35').should.deep.equal({})\r\n\t\t// Too long.\r\n\t\tparseNumber('+7 (800) 55-35-35-55').should.deep.equal({})\r\n\r\n\t\tparseNumber('+7 (800) 55-35-35', 'US').should.deep.equal({})\r\n\t\tparseNumber('(800) 55 35 35', { defaultCountry: 'RU' }).should.deep.equal({})\r\n\t\tparseNumber('+1 187 215 5230', 'US').should.deep.equal({})\r\n\r\n\t\tparseNumber('911231231', 'BE').should.deep.equal({})\r\n\t})\r\n\r\n\tit('should parse valid phone numbers', () => {\r\n\t\t// Instant loans\r\n\t\t// https://www.youtube.com/watch?v=6e1pMrYH5jI\r\n\t\t//\r\n\t\t// Restrict to RU\r\n\t\tparseNumber('Phone: 8 (800) 555 35 35.', 'RU').should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\t\t// International format\r\n\t\tparseNumber('Phone: +7 (800) 555-35-35.').should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\t\t// // Restrict to US, but not a US country phone code supplied\r\n\t\t// parseNumber('+7 (800) 555-35-35', 'US').should.deep.equal({})\r\n\t\t// Restrict to RU\r\n\t\tparseNumber('(800) 555 35 35', 'RU').should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\t\t// Default to RU\r\n\t\tparseNumber('8 (800) 555 35 35', { defaultCountry: 'RU' }).should.deep.equal({ country: 'RU', phone: '8005553535' })\r\n\r\n\t\t// Gangster partyline\r\n\t\tparseNumber('+1-213-373-4253').should.deep.equal({ country: 'US', phone: '2133734253' })\r\n\r\n\t\t// Switzerland (just in case)\r\n\t\tparseNumber('044 668 18 00', 'CH').should.deep.equal({ country: 'CH', phone: '446681800' })\r\n\r\n\t\t// China, Beijing\r\n\t\tparseNumber('010-852644821', 'CN').should.deep.equal({ country: 'CN', phone: '10852644821' })\r\n\r\n\t\t// France\r\n\t\tparseNumber('+33169454850').should.deep.equal({ country: 'FR', phone: '169454850' })\r\n\r\n\t\t// UK (Jersey)\r\n\t\tparseNumber('+44 7700 300000').should.deep.equal({ country: 'JE', phone: '7700300000' })\r\n\r\n\t\t// KZ\r\n\t\tparseNumber('+7 702 211 1111').should.deep.equal({ country: 'KZ', phone: '7022111111' })\r\n\r\n\t\t// Brazil\r\n\t\tparseNumber('11987654321', 'BR').should.deep.equal({ country: 'BR', phone: '11987654321' })\r\n\r\n\t\t// Long country phone code.\r\n\t\tparseNumber('+212659777777').should.deep.equal({ country: 'MA', phone: '659777777' })\r\n\r\n\t\t// No country could be derived.\r\n\t\t// parseNumber('+212569887076').should.deep.equal({ countryPhoneCode: '212', phone: '569887076' })\r\n\r\n\t\t// GB. Moible numbers starting 07624* are Isle of Man.\r\n\t\tparseNumber('07624369230', 'GB').should.deep.equal({ country: 'IM', phone: '7624369230' })\r\n\t})\r\n\r\n\tit('should parse possible numbers', () => {\r\n\t\t// Invalid phone number for a given country.\r\n\t\tparseNumber('1112223344', 'RU', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '1112223344',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// International phone number.\r\n\t\t// Several countries with the same country phone code.\r\n\t\tparseNumber('+71112223344').should.deep.equal({})\r\n\t\tparseNumber('+71112223344', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : undefined,\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '1112223344',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// International phone number.\r\n\t\t// Single country with the given country phone code.\r\n\t\tparseNumber('+33011222333', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'FR',\r\n\t\t\tcountryCallingCode : '33',\r\n\t\t\tphone : '011222333',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// Too short.\r\n\t\t// Won't strip national prefix `8` because otherwise the number would be too short.\r\n\t\tparseNumber('+7 (800) 55-35-35', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '800553535',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : false\r\n\t\t})\r\n\r\n\t\t// Too long.\r\n\t\tparseNumber('+1 213 37342530', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : undefined,\r\n\t\t\tcountryCallingCode : '1',\r\n\t\t\tphone : '21337342530',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : false,\r\n\t\t\tpossible : false\r\n\t\t})\r\n\r\n\t\t// No national number to be parsed.\r\n\t\tparseNumber('+996', { extended: true }).should.deep.equal({\r\n\t\t\t// countryCallingCode : '996'\r\n\t\t})\r\n\r\n\t\t// Valid number.\r\n\t\tparseNumber('+78005553535', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tcountryCallingCode : '7',\r\n\t\t\tphone : '8005553535',\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\text : undefined,\r\n\t\t\tvalid : true,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/211\r\n\t\tparseNumber('+966', { extended: true }).should.deep.equal({})\r\n\t\tparseNumber('+9664', { extended: true }).should.deep.equal({})\r\n\t\tparseNumber('+96645', { extended: true }).should.deep.equal({\r\n\t\t\tcarrierCode : undefined,\r\n\t\t\tphone : '45',\r\n\t\t\text : undefined,\r\n\t\t\tcountry : 'SA',\r\n\t\t\tcountryCallingCode : '966',\r\n\t\t\tpossible : false,\r\n\t\t\tvalid : false\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse non-European digits', () => {\r\n\t\tparseNumber('+١٢١٢٢٣٢٣٢٣٢').should.deep.equal({ country: 'US', phone: '2122323232' })\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\tlet thrower\r\n\r\n\t\t// No input\r\n\t\tparseNumber('').should.deep.equal({})\r\n\r\n\t\t// No country phone code\r\n\t\tparseNumber('+').should.deep.equal({})\r\n\r\n\t\t// No country at all (non international number and no explicit country code)\r\n\t\tparseNumber('123').should.deep.equal({})\r\n\r\n\t\t// No country metadata for this `require` country code\r\n\t\tthrower = () => parseNumber('123', 'ZZ')\r\n\t\tthrower.should.throw('Unknown country')\r\n\r\n\t\t// No country metadata for this `default` country code\r\n\t\tthrower = () => parseNumber('123', { defaultCountry: 'ZZ' })\r\n\t\tthrower.should.throw('Unknown country')\r\n\r\n\t\t// Invalid country phone code\r\n\t\tparseNumber('+210').should.deep.equal({})\r\n\r\n\t\t// Invalid country phone code (extended parsing mode)\r\n\t\tparseNumber('+210', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Too short of a number.\r\n\t\tparseNumber('1', 'US', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Too long of a number.\r\n\t\tparseNumber('1111111111111111111', 'RU', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Not a number.\r\n\t\tparseNumber('abcdefg', 'US', { extended: true }).should.deep.equal({})\r\n\r\n\t\t// Country phone code beginning with a '0'\r\n\t\tparseNumber('+0123').should.deep.equal({})\r\n\r\n\t\t// Barbados NANPA phone number\r\n\t\tparseNumber('+12460000000').should.deep.equal({ country: 'BB', phone: '2460000000' })\r\n\r\n\t\t// // A case when country (restricted to) is not equal\r\n\t\t// // to the one parsed out of an international number.\r\n\t\t// parseNumber('+1-213-373-4253', 'RU').should.deep.equal({})\r\n\r\n\t\t// National (significant) number too short\r\n\t\tparseNumber('2', 'US').should.deep.equal({})\r\n\r\n\t\t// National (significant) number too long\r\n\t\tparseNumber('222222222222222222', 'US').should.deep.equal({})\r\n\r\n\t\t// No `national_prefix_for_parsing`\r\n\t\tparseNumber('41111', 'AC').should.deep.equal({ country: 'AC', phone: '41111'})\r\n\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/235\r\n\t\t// `matchesEntirely()` bug fix.\r\n\t\tparseNumber('+4915784846111').should.deep.equal({ country: 'DE', phone: '15784846111' })\r\n\r\n\t\t// No metadata\r\n\t\tthrower = () => _parseNumber('')\r\n\t\tthrower.should.throw('`metadata` argument not passed')\r\n\r\n\t\t// Numerical `value`\r\n\t\tthrower = () => parseNumber(2141111111, 'US')\r\n\t\tthrower.should.throw('A text for parsing must be a string.')\r\n\r\n\t\t// Input string too long.\r\n\t\tparseNumber('8005553535 ', 'RU').should.deep.equal({})\r\n\t})\r\n\r\n\tit('should parse phone number extensions', () => {\r\n\t\t// \"ext\"\r\n\t\tparseNumber('2134567890 ext 123', 'US').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890',\r\n\t\t\text : '123'\r\n\t\t})\r\n\r\n\t\t// \"ext.\"\r\n\t\tparseNumber('+12134567890 ext. 12345', 'US').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890',\r\n\t\t\text : '12345'\r\n\t\t})\r\n\r\n\t\t// \"доб.\"\r\n\t\tparseNumber('+78005553535 доб. 1234', 'RU').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '1234'\r\n\t\t})\r\n\r\n\t\t// \"#\"\r\n\t\tparseNumber('+12134567890#1234').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890',\r\n\t\t\text : '1234'\r\n\t\t})\r\n\r\n\t\t// \"x\"\r\n\t\tparseNumber('+78005553535 x1234').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '1234'\r\n\t\t})\r\n\r\n\t\t// Not a valid extension\r\n\t\tparseNumber('2134567890 ext. abc', 'US').should.deep.equal({\r\n\t\t\tcountry : 'US',\r\n\t\t\tphone : '2134567890'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse RFC 3966 phone numbers', () => {\r\n\t\tparseNumber('tel:+78005553535;ext=123').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '123'\r\n\t\t})\r\n\r\n\t\t// Should parse \"visual separators\".\r\n\t\tparseNumber('tel:+7(800)555-35.35;ext=123').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535',\r\n\t\t\text : '123'\r\n\t\t})\r\n\r\n\t\t// Invalid number.\r\n\t\tparseNumber('tel:+7x8005553535;ext=123').should.deep.equal({})\r\n\t})\r\n\r\n\tit('should parse invalid international numbers even if they are invalid', () => {\r\n\t\tparseNumber('+7(8)8005553535', 'RU').should.deep.equal({\r\n\t\t\tcountry : 'RU',\r\n\t\t\tphone : '8005553535'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse carrier codes', () => {\r\n\t\tparseNumber('0 15 21 5555-5555', 'BR', { extended: true }).should.deep.equal({\r\n\t\t\tcountry : 'BR',\r\n\t\t\tcountryCallingCode : '55',\r\n\t\t\tphone : '2155555555',\r\n\t\t\tcarrierCode : '15',\r\n\t\t\text : undefined,\r\n\t\t\tvalid : true,\r\n\t\t\tpossible : true\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse IDD prefixes', () => {\r\n\t\tparseNumber('011 61 2 3456 7890', 'US').should.deep.equal({\r\n\t\t\tphone : '234567890',\r\n\t\t\tcountry : 'AU'\r\n\t\t})\r\n\r\n\t\tparseNumber('011 61 2 3456 7890', 'FR').should.deep.equal({})\r\n\r\n\t\tparseNumber('00 61 2 3456 7890', 'US').should.deep.equal({})\r\n\r\n\t\tparseNumber('810 61 2 3456 7890', 'RU').should.deep.equal({\r\n\t\t\tphone : '234567890',\r\n\t\t\tcountry : 'AU'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should work with v2 API', () => {\r\n\t\tparseNumber('+99989160151539')\r\n\t})\r\n\r\n\tit('should work with Argentina numbers', () => {\r\n\t\t// The same mobile number is written differently\r\n\t\t// in different formats in Argentina:\r\n\t\t// `9` gets prepended in international format.\r\n\t\tparseNumber('+54 9 3435 55 1212').should.deep.equal({\r\n\t\t\tcountry: 'AR',\r\n\t\t\tphone: '93435551212'\r\n\t\t})\r\n\t\tparseNumber('0343 15-555-1212', 'AR').should.deep.equal({\r\n\t\t\tcountry: 'AR',\r\n\t\t\tphone: '93435551212'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should work with Mexico numbers', () => {\r\n\t\t// Fixed line.\r\n\t\tparseNumber('+52 449 978 0001').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '4499780001'\r\n\t\t})\r\n\t\tparseNumber('01 (449)978-0001', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '4499780001'\r\n\t\t})\r\n\t\tparseNumber('(449)978-0001', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '4499780001'\r\n\t\t})\r\n\t\t// Mobile.\r\n\t\t// `1` is prepended before area code to mobile numbers in international format.\r\n\t\tparseNumber('+52 1 33 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t\tparseNumber('+52 33 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t\tparseNumber('044 (33) 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t\tparseNumber('045 33 1234-5678', 'MX').should.deep.equal({\r\n\t\t\tcountry: 'MX',\r\n\t\t\tphone: '3312345678'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers', () => {\r\n\t\tparseNumber('+870773111632').should.deep.equal(\r\n\t\t\tUSE_NON_GEOGRAPHIC_COUNTRY_CODE ?\r\n\t\t\t{\r\n\t\t\t\tcountry: '001',\r\n\t\t\t\tphone: '773111632'\r\n\t\t\t} :\r\n\t\t\t{}\r\n\t\t)\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (default country code)', () => {\r\n\t\tparseNumber('773111632', { defaultCallingCode: '870' }).should.deep.equal(\r\n\t\t\tUSE_NON_GEOGRAPHIC_COUNTRY_CODE ?\r\n\t\t\t{\r\n\t\t\t\tcountry: '001',\r\n\t\t\t\tphone: '773111632'\r\n\t\t\t} :\r\n\t\t\t{}\r\n\t\t)\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (extended)', () => {\r\n\t\tparseNumber('+870773111632', { extended: true }).should.deep.equal({\r\n\t\t\tcountry: USE_NON_GEOGRAPHIC_COUNTRY_CODE ? '001' : undefined,\r\n\t\t\tcountryCallingCode: '870',\r\n\t\t\tphone: '773111632',\r\n\t\t\tcarrierCode: undefined,\r\n\t\t\text: undefined,\r\n\t\t\tpossible: true,\r\n\t\t\tvalid: true\r\n\t\t})\r\n\t})\r\n\r\n\tit('should parse non-geographic numbering plan phone numbers (default country code) (extended)', () => {\r\n\t\tparseNumber('773111632', { defaultCallingCode: '870', extended: true }).should.deep.equal({\r\n\t\t\tcountry: USE_NON_GEOGRAPHIC_COUNTRY_CODE ? '001' : undefined,\r\n\t\t\tcountryCallingCode: '870',\r\n\t\t\tphone: '773111632',\r\n\t\t\tcarrierCode: undefined,\r\n\t\t\text: undefined,\r\n\t\t\tpossible: true,\r\n\t\t\tvalid: true\r\n\t\t})\r\n\t})\r\n\r\n\tit('shouldn\\'t crash when invalid `defaultCallingCode` is passed', () => {\r\n\t\texpect(() => parseNumber('773111632', { defaultCallingCode: '999' }))\r\n\t\t\t.to.throw('Unknown calling code')\r\n\t})\r\n\r\n\tit('shouldn\\'t set `country` when there\\'s no `defaultCountry` and `defaultCallingCode` is not of a \"non-geographic entity\"', () => {\r\n\t\tparseNumber('88005553535', { defaultCallingCode: '7' }).should.deep.equal({\r\n\t\t\tcountry: 'RU',\r\n\t\t\tphone: '8005553535'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should correctly parse numbers starting with the same digit as the national prefix', () => {\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/373\r\n\t\t// `BY`'s `national_prefix` is `8`.\r\n\t\tparseNumber('+37582004910060').should.deep.equal({\r\n\t\t\tcountry: 'BY',\r\n\t\t\tphone: '82004910060'\r\n\t\t});\r\n\t})\r\n\r\n\tit('should autocorrect numbers without a leading +', () => {\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/376\r\n\t\tparseNumber('375447521111', 'BY').should.deep.equal({\r\n\t\t\tcountry: 'BY',\r\n\t\t\tphone: '447521111'\r\n\t\t});\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/316\r\n\t\tparseNumber('33612902554', 'FR').should.deep.equal({\r\n\t\t\tcountry: 'FR',\r\n\t\t\tphone: '612902554'\r\n\t\t});\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/375\r\n\t\tparseNumber('61438331999', 'AU').should.deep.equal({\r\n\t\t\tcountry: 'AU',\r\n\t\t\tphone: '438331999'\r\n\t\t});\r\n\t\t// A case when `49` is a country calling code of a number without a leading `+`.\r\n\t\tparseNumber('4930123456', 'DE').should.deep.equal({\r\n\t\t\tcountry: 'DE',\r\n\t\t\tphone: '30123456'\r\n\t\t});\r\n\t\t// A case when `49` is a valid area code.\r\n\t\tparseNumber('4951234567890', 'DE').should.deep.equal({\r\n\t\t\tcountry: 'DE',\r\n\t\t\tphone: '4951234567890'\r\n\t\t});\r\n\t})\r\n\r\n\tit('should parse extensions (long extensions with explicitl abels)', () => {\r\n\t\t// Test lower and upper limits of extension lengths for each type of label.\r\n\r\n\t\t// Firstly, when in RFC format: PhoneNumberUtil.extLimitAfterExplicitLabel\r\n\t\tparseNumber('33316005 ext 0', 'NZ').ext.should.equal('0')\r\n\t\tparseNumber('33316005 ext 01234567890123456789', 'NZ').ext.should.equal('01234567890123456789')\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('33316005 ext 012345678901234567890', 'NZ').ext).to.be.undefined\r\n\r\n\t\t// Explicit extension label.\r\n\t\tparseNumber('03 3316005ext:1', 'NZ').ext.should.equal('1')\r\n\t\tparseNumber('03 3316005 xtn:12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 extension\\t12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 xtensio:12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 xtensión, 12345678901234567890#', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005extension.12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\t\tparseNumber('03 3316005 доб:12345678901234567890', 'NZ').ext.should.equal('12345678901234567890')\r\n\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('03 3316005 extension 123456789012345678901', 'NZ').ext).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse extensions (long extensions with auto dialling labels)', () => {\r\n\t\tparseNumber('+12679000000,,123456789012345#').ext.should.equal('123456789012345')\r\n\t\tparseNumber('+12679000000;123456789012345#').ext.should.equal('123456789012345')\r\n\t\tparseNumber('+442034000000,,123456789#').ext.should.equal('123456789')\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('+12679000000,,1234567890123456#').ext).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse extensions (short extensions with ambiguous characters)', () => {\r\n\t\tparseNumber('03 3316005 x 123456789', 'NZ').ext.should.equal('123456789')\r\n\t\tparseNumber('03 3316005 x. 123456789', 'NZ').ext.should.equal('123456789')\r\n\t\tparseNumber('03 3316005 #123456789#', 'NZ').ext.should.equal('123456789')\r\n\t\tparseNumber('03 3316005 ~ 123456789', 'NZ').ext.should.equal('123456789')\r\n\t\t// Extension too long.\r\n\t\texpect(parseNumber('03 3316005 ~ 1234567890', 'NZ').ext).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse extensions (short extensions when not sure of label)', () => {\r\n\t\tparseNumber('+1123-456-7890 666666#', { v2: true }).ext.should.equal('666666')\r\n\t\tparseNumber('+11234567890-6#', { v2: true }).ext.should.equal('6')\r\n\t\t// Extension too long.\r\n\t\texpect(() => parseNumber('+1123-456-7890 7777777#', { v2: true })).to.throw('NOT_A_NUMBER')\r\n\t})\r\n})"],"file":"parse.test.js"}
|
|
@@ -72,10 +72,20 @@ describe('parsePhoneNumber', function () {
|
|
|
72
72
|
return parsePhoneNumber('8005553535', 'XX');
|
|
73
73
|
}).to["throw"]('INVALID_COUNTRY');
|
|
74
74
|
expect(function () {
|
|
75
|
-
return parsePhoneNumber('
|
|
76
|
-
}).to["throw"]('NOT_A_NUMBER');
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
return parsePhoneNumber('+', 'RU');
|
|
76
|
+
}).to["throw"]('NOT_A_NUMBER');
|
|
77
|
+
expect(function () {
|
|
78
|
+
return parsePhoneNumber('a', 'RU');
|
|
79
|
+
}).to["throw"]('NOT_A_NUMBER');
|
|
80
|
+
expect(function () {
|
|
81
|
+
return parsePhoneNumber('1', 'RU');
|
|
82
|
+
}).to["throw"]('TOO_SHORT');
|
|
83
|
+
expect(function () {
|
|
84
|
+
return parsePhoneNumber('+4');
|
|
85
|
+
}).to["throw"]('TOO_SHORT');
|
|
86
|
+
expect(function () {
|
|
87
|
+
return parsePhoneNumber('+44');
|
|
88
|
+
}).to["throw"]('TOO_SHORT');
|
|
79
89
|
expect(function () {
|
|
80
90
|
return parsePhoneNumber('+443');
|
|
81
91
|
}).to["throw"]('TOO_SHORT');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/parsePhoneNumber.test.js"],"names":["_parsePhoneNumber","metadata","metadataFull","parsePhoneNumber","parameters","push","apply","parsePhoneNumberFull","describe","it","phoneNumber","country","should","equal","countryCallingCode","nationalNumber","number","isPossible","isValid","getType","expect","to","be","undefined","carrierCode","ext","format","formatNational","formatInternational","getURI"],"mappings":"AAAA,OAAOA,iBAAP,MAA8B,oBAA9B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,OAAOC,YAAP,MAAyB,uBAAzB;;AAEA,SAASC,gBAAT,GAAyC;AAAA,oCAAZC,UAAY;AAAZA,IAAAA,UAAY;AAAA;;AACxCA,EAAAA,UAAU,CAACC,IAAX,CAAgBJ,QAAhB;AACA,SAAOD,iBAAiB,CAACM,KAAlB,CAAwB,IAAxB,EAA8BF,UAA9B,CAAP;AACA;;AAED,SAASG,oBAAT,GAA6C;AAAA,qCAAZH,UAAY;AAAZA,IAAAA,UAAY;AAAA;;AAC5CA,EAAAA,UAAU,CAACC,IAAX,CAAgBH,YAAhB;AACA,SAAOF,iBAAiB,CAACM,KAAlB,CAAwB,IAAxB,EAA8BF,UAA9B,CAAP;AACA;;AAEDI,QAAQ,CAAC,kBAAD,EAAqB,YAAM;AAClCC,EAAAA,EAAE,CAAC,4BAAD,EAA+B,YAAM;AACtC,QAAMC,WAAW,GAAGP,gBAAgB,CAAC,2BAAD,EAA8B,IAA9B,CAApC;AACAO,IAAAA,WAAW,CAACC,OAAZ,CAAoBC,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC;AACAH,IAAAA,WAAW,CAACI,kBAAZ,CAA+BF,MAA/B,CAAsCC,KAAtC,CAA4C,GAA5C;AACAH,IAAAA,WAAW,CAACK,cAAZ,CAA2BH,MAA3B,CAAkCC,KAAlC,CAAwC,YAAxC;AACAH,IAAAA,WAAW,CAACM,MAAZ,CAAmBJ,MAAnB,CAA0BC,KAA1B,CAAgC,cAAhC;AACAH,IAAAA,WAAW,CAACO,UAAZ,GAAyBL,MAAzB,CAAgCC,KAAhC,CAAsC,IAAtC;AACAH,IAAAA,WAAW,CAACQ,OAAZ,GAAsBN,MAAtB,CAA6BC,KAA7B,CAAmC,IAAnC,E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8D,CAkB9D;;AACAH,IAAAA,WAAW,GAAGP,gBAAgB,CAAC,kBAAD,CAA9B;AACAO,IAAAA,WAAW,CAACK,cAAZ,CAA2BH,MAA3B,CAAkCC,KAAlC,CAAwC,YAAxC;AACAH,IAAAA,WAAW,CAACC,OAAZ,CAAoBC,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC,EArB8D,CAuB9D;;AACAH,IAAAA,WAAW,GAAGP,gBAAgB,CAAC,iBAAD,CAA9B;AACAO,IAAAA,WAAW,CAACK,cAAZ,CAA2BH,MAA3B,CAAkCC,KAAlC,CAAwC,YAAxC;AACAH,IAAAA,WAAW,CAACC,OAAZ,CAAoBC,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC;AACA,GA3BC,CAAF;AA4BA,CA/FO,CAAR","sourcesContent":["import _parsePhoneNumber from './parsePhoneNumber'\r\nimport metadata from '../metadata.min.json'\r\nimport metadataFull from '../metadata.full.json'\r\n\r\nfunction parsePhoneNumber(...parameters) {\r\n\tparameters.push(metadata)\r\n\treturn _parsePhoneNumber.apply(this, parameters)\r\n}\r\n\r\nfunction parsePhoneNumberFull(...parameters) {\r\n\tparameters.push(metadataFull)\r\n\treturn _parsePhoneNumber.apply(this, parameters)\r\n}\r\n\r\ndescribe('parsePhoneNumber', () => {\r\n\tit('should parse phone numbers', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35.', 'RU')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.nationalNumber.should.equal('8005553535')\r\n\t\tphoneNumber.number.should.equal('+78005553535')\r\n\t\tphoneNumber.isPossible().should.equal(true)\r\n\t\tphoneNumber.isValid().should.equal(true)\r\n\t\t// phoneNumber.isValidForRegion('RU').should.equal(true)\r\n\t\t// Russian phone type regexps aren't included in default metadata.\r\n\t\tparsePhoneNumberFull('Phone: 8 (800) 555 35 35.', 'RU').getType().should.equal('TOLL_FREE')\r\n\t})\r\n\r\n\tit('shouldn\\'t set country when it\\'s non-derivable', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('+7 111 555 35 35')\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.nationalNumber.should.equal('1115553535')\r\n\t})\r\n\r\n\tit('should parse carrier code', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('0 15 21 5555-5555', 'BR')\r\n\t\tphoneNumber.carrierCode.should.equal('15')\r\n\t})\r\n\r\n\tit('should parse phone extension', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35 ext. 1234.', 'RU')\r\n\t\tphoneNumber.ext.should.equal('1234')\r\n\t})\r\n\r\n\tit('should validate numbers for countries with no type regular expressions', () => {\r\n\t\tparsePhoneNumber('+380391234567').isValid().should.equal(true)\r\n\t\tparsePhoneNumber('+380191234567').isValid().should.equal(false)\r\n\t})\r\n\r\n\tit('should format numbers', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35.', 'RU')\r\n\t\tphoneNumber.format('NATIONAL').should.equal('8 (800) 555-35-35')\r\n\t\tphoneNumber.formatNational().should.equal('8 (800) 555-35-35')\r\n\t\tphoneNumber.format('INTERNATIONAL').should.equal('+7 800 555 35 35')\r\n\t\tphoneNumber.formatInternational().should.equal('+7 800 555 35 35')\r\n\t})\r\n\r\n\tit('should get tel: URI', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35 ext. 1234.', 'RU')\r\n\t\tphoneNumber.getURI().should.equal('tel:+78005553535;ext=1234')\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\texpect(() => parsePhoneNumber('+78005553535', -1, {})).to.throw('Invalid second argument')\r\n\t})\r\n\r\n\tit('should throw parse errors', () => {\r\n\t\texpect(() => parsePhoneNumber('8005553535', 'XX')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('8', 'RU')).to.throw('NOT_A_NUMBER')\r\n\t\t// Won't throw here because the regexp already demands length > 1.\r\n\t\t// expect(() => parsePhoneNumber('11', 'RU')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('+443')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('+370')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('88888888888888888888', 'RU')).to.throw('TOO_LONG')\r\n\t\texpect(() => parsePhoneNumber('8 (800) 555 35 35')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('+9991112233')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('+9991112233', 'US')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('8005553535 ', 'RU')).to.throw('TOO_LONG')\r\n\t})\r\n\r\n\tit('should parse incorrect international phone numbers', () => {\r\n\t\t// Parsing national prefixes and carrier codes\r\n\t\t// is only required for local phone numbers\r\n\t\t// but some people don't understand that\r\n\t\t// and sometimes write international phone numbers\r\n\t\t// with national prefixes (or maybe even carrier codes).\r\n\t\t// http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html\r\n\t\t// Google's original library forgives such mistakes\r\n\t\t// and so does this library, because it has been requested:\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/127\r\n\r\n\t\tlet phoneNumber\r\n\r\n\t\t// For complete numbers it should strip national prefix.\r\n\t\tphoneNumber = parsePhoneNumber('+1 1877 215 5230')\r\n\t\tphoneNumber.nationalNumber.should.equal('8772155230')\r\n\t\tphoneNumber.country.should.equal('US')\r\n\r\n\t\t// For complete numbers it should strip national prefix.\r\n\t\tphoneNumber = parsePhoneNumber('+7 8800 555 3535')\r\n\t\tphoneNumber.nationalNumber.should.equal('8005553535')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\r\n\t\t// For incomplete numbers it shouldn't strip national prefix.\r\n\t\tphoneNumber = parsePhoneNumber('+7 8800 555 353')\r\n\t\tphoneNumber.nationalNumber.should.equal('8800555353')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t})\r\n})\r\n"],"file":"parsePhoneNumber.test.js"}
|
|
1
|
+
{"version":3,"sources":["../source/parsePhoneNumber.test.js"],"names":["_parsePhoneNumber","metadata","metadataFull","parsePhoneNumber","parameters","push","apply","parsePhoneNumberFull","describe","it","phoneNumber","country","should","equal","countryCallingCode","nationalNumber","number","isPossible","isValid","getType","expect","to","be","undefined","carrierCode","ext","format","formatNational","formatInternational","getURI"],"mappings":"AAAA,OAAOA,iBAAP,MAA8B,oBAA9B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,OAAOC,YAAP,MAAyB,uBAAzB;;AAEA,SAASC,gBAAT,GAAyC;AAAA,oCAAZC,UAAY;AAAZA,IAAAA,UAAY;AAAA;;AACxCA,EAAAA,UAAU,CAACC,IAAX,CAAgBJ,QAAhB;AACA,SAAOD,iBAAiB,CAACM,KAAlB,CAAwB,IAAxB,EAA8BF,UAA9B,CAAP;AACA;;AAED,SAASG,oBAAT,GAA6C;AAAA,qCAAZH,UAAY;AAAZA,IAAAA,UAAY;AAAA;;AAC5CA,EAAAA,UAAU,CAACC,IAAX,CAAgBH,YAAhB;AACA,SAAOF,iBAAiB,CAACM,KAAlB,CAAwB,IAAxB,EAA8BF,UAA9B,CAAP;AACA;;AAEDI,QAAQ,CAAC,kBAAD,EAAqB,YAAM;AAClCC,EAAAA,EAAE,CAAC,4BAAD,EAA+B,YAAM;AACtC,QAAMC,WAAW,GAAGP,gBAAgB,CAAC,2BAAD,EAA8B,IAA9B,CAApC;AACAO,IAAAA,WAAW,CAACC,OAAZ,CAAoBC,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC;AACAH,IAAAA,WAAW,CAACI,kBAAZ,CAA+BF,MAA/B,CAAsCC,KAAtC,CAA4C,GAA5C;AACAH,IAAAA,WAAW,CAACK,cAAZ,CAA2BH,MAA3B,CAAkCC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_parsePhoneNumber from './parsePhoneNumber'\r\nimport metadata from '../metadata.min.json'\r\nimport metadataFull from '../metadata.full.json'\r\n\r\nfunction parsePhoneNumber(...parameters) {\r\n\tparameters.push(metadata)\r\n\treturn _parsePhoneNumber.apply(this, parameters)\r\n}\r\n\r\nfunction parsePhoneNumberFull(...parameters) {\r\n\tparameters.push(metadataFull)\r\n\treturn _parsePhoneNumber.apply(this, parameters)\r\n}\r\n\r\ndescribe('parsePhoneNumber', () => {\r\n\tit('should parse phone numbers', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35.', 'RU')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.nationalNumber.should.equal('8005553535')\r\n\t\tphoneNumber.number.should.equal('+78005553535')\r\n\t\tphoneNumber.isPossible().should.equal(true)\r\n\t\tphoneNumber.isValid().should.equal(true)\r\n\t\t// phoneNumber.isValidForRegion('RU').should.equal(true)\r\n\t\t// Russian phone type regexps aren't included in default metadata.\r\n\t\tparsePhoneNumberFull('Phone: 8 (800) 555 35 35.', 'RU').getType().should.equal('TOLL_FREE')\r\n\t})\r\n\r\n\tit('shouldn\\'t set country when it\\'s non-derivable', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('+7 111 555 35 35')\r\n\t\texpect(phoneNumber.country).to.be.undefined\r\n\t\tphoneNumber.countryCallingCode.should.equal('7')\r\n\t\tphoneNumber.nationalNumber.should.equal('1115553535')\r\n\t})\r\n\r\n\tit('should parse carrier code', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('0 15 21 5555-5555', 'BR')\r\n\t\tphoneNumber.carrierCode.should.equal('15')\r\n\t})\r\n\r\n\tit('should parse phone extension', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35 ext. 1234.', 'RU')\r\n\t\tphoneNumber.ext.should.equal('1234')\r\n\t})\r\n\r\n\tit('should validate numbers for countries with no type regular expressions', () => {\r\n\t\tparsePhoneNumber('+380391234567').isValid().should.equal(true)\r\n\t\tparsePhoneNumber('+380191234567').isValid().should.equal(false)\r\n\t})\r\n\r\n\tit('should format numbers', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35.', 'RU')\r\n\t\tphoneNumber.format('NATIONAL').should.equal('8 (800) 555-35-35')\r\n\t\tphoneNumber.formatNational().should.equal('8 (800) 555-35-35')\r\n\t\tphoneNumber.format('INTERNATIONAL').should.equal('+7 800 555 35 35')\r\n\t\tphoneNumber.formatInternational().should.equal('+7 800 555 35 35')\r\n\t})\r\n\r\n\tit('should get tel: URI', () => {\r\n\t\tconst phoneNumber = parsePhoneNumber('Phone: 8 (800) 555 35 35 ext. 1234.', 'RU')\r\n\t\tphoneNumber.getURI().should.equal('tel:+78005553535;ext=1234')\r\n\t})\r\n\r\n\tit('should work in edge cases', () => {\r\n\t\texpect(() => parsePhoneNumber('+78005553535', -1, {})).to.throw('Invalid second argument')\r\n\t})\r\n\r\n\tit('should throw parse errors', () => {\r\n\t\texpect(() => parsePhoneNumber('8005553535', 'XX')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('+', 'RU')).to.throw('NOT_A_NUMBER')\r\n\t\texpect(() => parsePhoneNumber('a', 'RU')).to.throw('NOT_A_NUMBER')\r\n\t\texpect(() => parsePhoneNumber('1', 'RU')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('+4')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('+44')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('+443')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('+370')).to.throw('TOO_SHORT')\r\n\t\texpect(() => parsePhoneNumber('88888888888888888888', 'RU')).to.throw('TOO_LONG')\r\n\t\texpect(() => parsePhoneNumber('8 (800) 555 35 35')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('+9991112233')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('+9991112233', 'US')).to.throw('INVALID_COUNTRY')\r\n\t\texpect(() => parsePhoneNumber('8005553535 ', 'RU')).to.throw('TOO_LONG')\r\n\t})\r\n\r\n\tit('should parse incorrect international phone numbers', () => {\r\n\t\t// Parsing national prefixes and carrier codes\r\n\t\t// is only required for local phone numbers\r\n\t\t// but some people don't understand that\r\n\t\t// and sometimes write international phone numbers\r\n\t\t// with national prefixes (or maybe even carrier codes).\r\n\t\t// http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html\r\n\t\t// Google's original library forgives such mistakes\r\n\t\t// and so does this library, because it has been requested:\r\n\t\t// https://github.com/catamphetamine/libphonenumber-js/issues/127\r\n\r\n\t\tlet phoneNumber\r\n\r\n\t\t// For complete numbers it should strip national prefix.\r\n\t\tphoneNumber = parsePhoneNumber('+1 1877 215 5230')\r\n\t\tphoneNumber.nationalNumber.should.equal('8772155230')\r\n\t\tphoneNumber.country.should.equal('US')\r\n\r\n\t\t// For complete numbers it should strip national prefix.\r\n\t\tphoneNumber = parsePhoneNumber('+7 8800 555 3535')\r\n\t\tphoneNumber.nationalNumber.should.equal('8005553535')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\r\n\t\t// For incomplete numbers it shouldn't strip national prefix.\r\n\t\tphoneNumber = parsePhoneNumber('+7 8800 555 353')\r\n\t\tphoneNumber.nationalNumber.should.equal('8800555353')\r\n\t\tphoneNumber.country.should.equal('RU')\r\n\t})\r\n})\r\n"],"file":"parsePhoneNumber.test.js"}
|
package/es6/parse_.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { VALID_DIGITS, PLUS_CHARS, MIN_LENGTH_FOR_NSN, MAX_LENGTH_FOR_NSN } from './constants';
|
|
6
6
|
import ParseError from './ParseError';
|
|
7
7
|
import Metadata from './metadata';
|
|
8
|
-
import isViablePhoneNumber from './helpers/isViablePhoneNumber';
|
|
8
|
+
import isViablePhoneNumber, { isViablePhoneNumberStart } from './helpers/isViablePhoneNumber';
|
|
9
9
|
import extractExtension from './helpers/extension/extractExtension';
|
|
10
10
|
import parseIncompletePhoneNumber from './parseIncompletePhoneNumber';
|
|
11
11
|
import getCountryCallingCode from './getCountryCallingCode';
|
|
@@ -56,11 +56,16 @@ export default function parse(text, options, metadata) {
|
|
|
56
56
|
|
|
57
57
|
var _parseInput = parseInput(text, options.v2, options.extract),
|
|
58
58
|
formattedPhoneNumber = _parseInput.number,
|
|
59
|
-
ext = _parseInput.ext
|
|
59
|
+
ext = _parseInput.ext,
|
|
60
|
+
error = _parseInput.error; // If the phone number is not viable then return nothing.
|
|
60
61
|
|
|
61
62
|
|
|
62
63
|
if (!formattedPhoneNumber) {
|
|
63
64
|
if (options.v2) {
|
|
65
|
+
if (error === 'TOO_SHORT') {
|
|
66
|
+
throw new ParseError('TOO_SHORT');
|
|
67
|
+
}
|
|
68
|
+
|
|
64
69
|
throw new ParseError('NOT_A_NUMBER');
|
|
65
70
|
}
|
|
66
71
|
|
|
@@ -207,7 +212,17 @@ function parseInput(text, v2, extract) {
|
|
|
207
212
|
|
|
208
213
|
var number = extractFormattedPhoneNumber(text, extract, v2); // If the phone number is not viable, then abort.
|
|
209
214
|
|
|
210
|
-
if (!number
|
|
215
|
+
if (!number) {
|
|
216
|
+
return {};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (!isViablePhoneNumber(number)) {
|
|
220
|
+
if (isViablePhoneNumberStart(number)) {
|
|
221
|
+
return {
|
|
222
|
+
error: 'TOO_SHORT'
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
211
226
|
return {};
|
|
212
227
|
} // Attempt to parse extension first, since it doesn't require region-specific
|
|
213
228
|
// data and we want to have the non-normalised number here.
|
package/es6/parse_.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/parse_.js"],"names":["VALID_DIGITS","PLUS_CHARS","MIN_LENGTH_FOR_NSN","MAX_LENGTH_FOR_NSN","ParseError","Metadata","isViablePhoneNumber","extractExtension","parseIncompletePhoneNumber","getCountryCallingCode","isPossibleNumber","parseRFC3966","PhoneNumber","matchesEntirely","extractCountryCallingCode","extractCountryCallingCodeFromInternationalNumberWithoutPlusSign","extractNationalNumber","stripIddPrefix","getCountryByCallingCode","MAX_INPUT_STRING_LENGTH","PHONE_NUMBER_START_PATTERN","RegExp","AFTER_PHONE_NUMBER_END_PATTERN","USE_NON_GEOGRAPHIC_COUNTRY_CODE","parse","text","options","metadata","defaultCountry","hasCountry","v2","Error","parseInput","extract","formattedPhoneNumber","number","ext","parsePhoneNumber","defaultCallingCode","country","nationalNumber","countryCallingCode","carrierCode","hasSelectedNumberingPlan","length","phoneNumber","valid","extended","nationalNumberPattern","result","possible","possibleLengths","phone","extractFormattedPhoneNumber","throwOnError","startsAt","search","slice","replace","indexOf","withExtensionStripped","selectNumberingPlan","isNonGeographicCallingCode","exactCountry"],"mappings":"AAAA;AACA;AACA;AACA;AAEA,SACCA,YADD,EAECC,UAFD,EAGCC,kBAHD,EAICC,kBAJD,QAKO,aALP;AAOA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,mBAAP,MAAgC,+BAAhC;AACA,OAAOC,gBAAP,MAA6B,sCAA7B;AACA,OAAOC,0BAAP,MAAuC,8BAAvC;AACA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AACA,SAASC,YAAT,QAA6B,mBAA7B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,eAAP,MAA4B,2BAA5B;AACA,OAAOC,yBAAP,MAAsC,qCAAtC;AACA,OAAOC,+DAAP,MAA4E,2EAA5E;AACA,OAAOC,qBAAP,MAAkC,iCAAlC;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,uBAAP,MAAoC,mCAApC,C,CAEA;AACA;;A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AArC,CAA5C;;AACA,MAAIoC,YAAJ,EAAkB;AACjBxB,IAAAA,OAAO,GAAGwB,YAAV;AACA;;AACA,QAAIA,YAAY,KAAK,KAArB,EAA4B,CAC3B;AACA;AACA;AACA,KAJD,MAIO;AACNpC,MAAAA,QAAQ,CAACY,OAAT,CAAiBA,OAAjB;AACA;AACD;;AAED,SAAO;AACNA,IAAAA,OAAO,EAAPA,OADM;AAENE,IAAAA,kBAAkB,EAAlBA,kBAFM;AAGND,IAAAA,cAAc,EAAdA,cAHM;AAINE,IAAAA,WAAW,EAAXA;AAJM,GAAP;AAMA","sourcesContent":["// This is a port of Google Android `libphonenumber`'s\r\n// `phonenumberutil.js` of December 31th, 2018.\r\n//\r\n// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js\r\n\r\nimport {\r\n\tVALID_DIGITS,\r\n\tPLUS_CHARS,\r\n\tMIN_LENGTH_FOR_NSN,\r\n\tMAX_LENGTH_FOR_NSN\r\n} from './constants'\r\n\r\nimport ParseError from './ParseError'\r\nimport Metadata from './metadata'\r\nimport isViablePhoneNumber from './helpers/isViablePhoneNumber'\r\nimport extractExtension from './helpers/extension/extractExtension'\r\nimport parseIncompletePhoneNumber from './parseIncompletePhoneNumber'\r\nimport getCountryCallingCode from './getCountryCallingCode'\r\nimport { isPossibleNumber } from './isPossibleNumber_'\r\nimport { parseRFC3966 } from './helpers/RFC3966'\r\nimport PhoneNumber from './PhoneNumber'\r\nimport matchesEntirely from './helpers/matchesEntirely'\r\nimport extractCountryCallingCode from './helpers/extractCountryCallingCode'\r\nimport extractCountryCallingCodeFromInternationalNumberWithoutPlusSign from './helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign'\r\nimport extractNationalNumber from './helpers/extractNationalNumber'\r\nimport stripIddPrefix from './helpers/stripIddPrefix'\r\nimport getCountryByCallingCode from './helpers/getCountryByCallingCode'\r\n\r\n// We don't allow input strings for parsing to be longer than 250 chars.\r\n// This prevents malicious input from consuming CPU.\r\nconst MAX_INPUT_STRING_LENGTH = 250\r\n\r\n// This consists of the plus symbol, digits, and arabic-indic digits.\r\nconst PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']')\r\n\r\n// Regular expression of trailing characters that we want to remove.\r\n// A trailing `#` is sometimes used when writing phone numbers with extensions in US.\r\n// Example: \"+1 (645) 123 1234-910#\" number has extension \"910\".\r\nconst AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$')\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\n// Examples:\r\n//\r\n// ```js\r\n// parse('8 (800) 555-35-35', 'RU')\r\n// parse('8 (800) 555-35-35', 'RU', metadata)\r\n// parse('8 (800) 555-35-35', { country: { default: 'RU' } })\r\n// parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)\r\n// parse('+7 800 555 35 35')\r\n// parse('+7 800 555 35 35', metadata)\r\n// ```\r\n//\r\nexport default function parse(text, options, metadata) {\r\n\t// If assigning the `{}` default value is moved to the arguments above,\r\n\t// code coverage would decrease for some weird reason.\r\n\toptions = options || {}\r\n\r\n\tmetadata = new Metadata(metadata)\r\n\r\n\t// Validate `defaultCountry`.\r\n\tif (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('INVALID_COUNTRY')\r\n\t\t}\r\n\t\tthrow new Error(`Unknown country: ${options.defaultCountry}`)\r\n\t}\r\n\r\n\t// Parse the phone number.\r\n\tconst { number: formattedPhoneNumber, ext } = parseInput(text, options.v2, options.extract)\r\n\r\n\t// If the phone number is not viable then return nothing.\r\n\tif (!formattedPhoneNumber) {\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('NOT_A_NUMBER')\r\n\t\t}\r\n\t\treturn {}\r\n\t}\r\n\r\n\tconst {\r\n\t\tcountry,\r\n\t\tnationalNumber,\r\n\t\tcountryCallingCode,\r\n\t\tcarrierCode\r\n\t} = parsePhoneNumber(\r\n\t\tformattedPhoneNumber,\r\n\t\toptions.defaultCountry,\r\n\t\toptions.defaultCallingCode,\r\n\t\tmetadata\r\n\t)\r\n\r\n\tif (!metadata.hasSelectedNumberingPlan()) {\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('INVALID_COUNTRY')\r\n\t\t}\r\n\t\treturn {}\r\n\t}\r\n\r\n\t// Validate national (significant) number length.\r\n\tif (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {\r\n\t\t// Won't throw here because the regexp already demands length > 1.\r\n\t\t/* istanbul ignore if */\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('TOO_SHORT')\r\n\t\t}\r\n\t\t// Google's demo just throws an error in this case.\r\n\t\treturn {}\r\n\t}\r\n\r\n\t// Validate national (significant) number length.\r\n\t//\r\n\t// A sidenote:\r\n\t//\r\n\t// They say that sometimes national (significant) numbers\r\n\t// can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).\r\n\t// https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36\r\n\t// Such numbers will just be discarded.\r\n\t//\r\n\tif (nationalNumber.length > MAX_LENGTH_FOR_NSN) {\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('TOO_LONG')\r\n\t\t}\r\n\t\t// Google's demo just throws an error in this case.\r\n\t\treturn {}\r\n\t}\r\n\r\n\tif (options.v2) {\r\n\t\tconst phoneNumber = new PhoneNumber(\r\n\t\t\tcountryCallingCode,\r\n\t\t\tnationalNumber,\r\n\t\t\tmetadata.metadata\r\n\t\t)\r\n\t\tif (country) {\r\n\t\t\tphoneNumber.country = country\r\n\t\t}\r\n\t\tif (carrierCode) {\r\n\t\t\tphoneNumber.carrierCode = carrierCode\r\n\t\t}\r\n\t\tif (ext) {\r\n\t\t\tphoneNumber.ext = ext\r\n\t\t}\r\n\t\treturn phoneNumber\r\n\t}\r\n\r\n\t// Check if national phone number pattern matches the number.\r\n\t// National number pattern is different for each country,\r\n\t// even for those ones which are part of the \"NANPA\" group.\r\n\tconst valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ?\r\n\t\tmatchesEntirely(nationalNumber, metadata.nationalNumberPattern()) :\r\n\t\tfalse\r\n\r\n\tif (!options.extended) {\r\n\t\treturn valid ? result(country, nationalNumber, ext) : {}\r\n\t}\r\n\r\n\t// isInternational: countryCallingCode !== undefined\r\n\r\n\treturn {\r\n\t\tcountry,\r\n\t\tcountryCallingCode,\r\n\t\tcarrierCode,\r\n\t\tvalid,\r\n\t\tpossible: valid ? true : (\r\n\t\t\toptions.extended === true &&\r\n\t\t\tmetadata.possibleLengths() &&\r\n\t\t\tisPossibleNumber(nationalNumber, metadata) ? true : false\r\n\t\t),\r\n\t\tphone: nationalNumber,\r\n\t\text\r\n\t}\r\n}\r\n\r\n/**\r\n * Extracts a formatted phone number from text.\r\n * Doesn't guarantee that the extracted phone number\r\n * is a valid phone number (for example, doesn't validate its length).\r\n * @param {string} text\r\n * @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.\r\n * @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.\r\n * @return {string}\r\n * @example\r\n * // Returns \"(213) 373-4253\".\r\n * extractFormattedPhoneNumber(\"Call (213) 373-4253 for assistance.\")\r\n */\r\nfunction extractFormattedPhoneNumber(text, extract, throwOnError) {\r\n\tif (!text) {\r\n\t\treturn\r\n\t}\r\n\tif (text.length > MAX_INPUT_STRING_LENGTH) {\r\n\t\tif (throwOnError) {\r\n\t\t\tthrow new ParseError('TOO_LONG')\r\n\t\t}\r\n\t\treturn\r\n\t}\r\n\tif (extract === false) {\r\n\t\treturn text\r\n\t}\r\n\t// Attempt to extract a possible number from the string passed in\r\n\tconst startsAt = text.search(PHONE_NUMBER_START_PATTERN)\r\n\tif (startsAt < 0) {\r\n\t\treturn\r\n\t}\r\n\treturn text\r\n\t\t// Trim everything to the left of the phone number\r\n\t\t.slice(startsAt)\r\n\t\t// Remove trailing non-numerical characters\r\n\t\t.replace(AFTER_PHONE_NUMBER_END_PATTERN, '')\r\n}\r\n\r\n/**\r\n * @param {string} text - Input.\r\n * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.\r\n * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.\r\n * @return {object} `{ ?number, ?ext }`.\r\n */\r\nfunction parseInput(text, v2, extract) {\r\n\t// Parse RFC 3966 phone number URI.\r\n\tif (text && text.indexOf('tel:') === 0) {\r\n\t\treturn parseRFC3966(text)\r\n\t}\r\n\tlet number = extractFormattedPhoneNumber(text, extract, v2)\r\n\t// If the phone number is not viable, then abort.\r\n\tif (!number || !isViablePhoneNumber(number)) {\r\n\t\treturn {}\r\n\t}\r\n\t// Attempt to parse extension first, since it doesn't require region-specific\r\n\t// data and we want to have the non-normalised number here.\r\n\tconst withExtensionStripped = extractExtension(number)\r\n\tif (withExtensionStripped.ext) {\r\n\t\treturn withExtensionStripped\r\n\t}\r\n\treturn { number }\r\n}\r\n\r\n/**\r\n * Creates `parse()` result object.\r\n */\r\nfunction result(country, nationalNumber, ext) {\r\n\tconst result = {\r\n\t\tcountry,\r\n\t\tphone: nationalNumber\r\n\t}\r\n\tif (ext) {\r\n\t\tresult.ext = ext\r\n\t}\r\n\treturn result\r\n}\r\n\r\n/**\r\n * Parses a viable phone number.\r\n * @param {string} formattedPhoneNumber — Example: \"(213) 373-4253\".\r\n * @param {string} [defaultCountry]\r\n * @param {string} [defaultCallingCode]\r\n * @param {Metadata} metadata\r\n * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.\r\n */\r\nfunction parsePhoneNumber(\r\n\tformattedPhoneNumber,\r\n\tdefaultCountry,\r\n\tdefaultCallingCode,\r\n\tmetadata\r\n) {\r\n\t// Extract calling code from phone number.\r\n\tlet { countryCallingCode, number } = extractCountryCallingCode(\r\n\t\tparseIncompletePhoneNumber(formattedPhoneNumber),\r\n\t\tdefaultCountry,\r\n\t\tdefaultCallingCode,\r\n\t\tmetadata.metadata\r\n\t)\r\n\r\n\t// Choose a country by `countryCallingCode`.\r\n\tlet country\r\n\tif (countryCallingCode) {\r\n\t\tmetadata.selectNumberingPlan(countryCallingCode)\r\n\t}\r\n\t// If `formattedPhoneNumber` is in \"national\" format\r\n\t// then `number` is defined and `countryCallingCode` isn't.\r\n\telse if (number && (defaultCountry || defaultCallingCode)) {\r\n\t\tmetadata.selectNumberingPlan(defaultCountry, defaultCallingCode)\r\n\t\tif (defaultCountry) {\r\n\t\t\tcountry = defaultCountry\r\n\t\t} else {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (metadata.isNonGeographicCallingCode(defaultCallingCode)) {\r\n\t\t\t\t\tcountry = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tcountryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata)\r\n\t}\r\n\telse return {}\r\n\r\n\tif (!number) {\r\n\t\treturn { countryCallingCode }\r\n\t}\r\n\r\n\tconst {\r\n\t\tnationalNumber,\r\n\t\tcarrierCode\r\n\t} = extractNationalNumber(\r\n\t\tparseIncompletePhoneNumber(number),\r\n\t\tmetadata\r\n\t)\r\n\r\n\t// Sometimes there are several countries\r\n\t// corresponding to the same country phone code\r\n\t// (e.g. NANPA countries all having `1` country phone code).\r\n\t// Therefore, to reliably determine the exact country,\r\n\t// national (significant) number should have been parsed first.\r\n\t//\r\n\t// When `metadata.json` is generated, all \"ambiguous\" country phone codes\r\n\t// get their countries populated with the full set of\r\n\t// \"phone number type\" regular expressions.\r\n\t//\r\n\tconst exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata)\r\n\tif (exactCountry) {\r\n\t\tcountry = exactCountry\r\n\t\t/* istanbul ignore if */\r\n\t\tif (exactCountry === '001') {\r\n\t\t\t// Can't happen with `USE_NON_GEOGRAPHIC_COUNTRY_CODE` being `false`.\r\n\t\t\t// If `USE_NON_GEOGRAPHIC_COUNTRY_CODE` is set to `true` for some reason,\r\n\t\t\t// then remove the \"istanbul ignore if\".\r\n\t\t} else {\r\n\t\t\tmetadata.country(country)\r\n\t\t}\r\n\t}\r\n\r\n\treturn {\r\n\t\tcountry,\r\n\t\tcountryCallingCode,\r\n\t\tnationalNumber,\r\n\t\tcarrierCode\r\n\t}\r\n}"],"file":"parse_.js"}
|
|
1
|
+
{"version":3,"sources":["../source/parse_.js"],"names":["VALID_DIGITS","PLUS_CHARS","MIN_LENGTH_FOR_NSN","MAX_LENGTH_FOR_NSN","ParseError","Metadata","isViablePhoneNumber","isViablePhoneNumberStart","extractExtension","parseIncompletePhoneNumber","getCountryCallingCode","isPossibleNumber","parseRFC3966","PhoneNumber","matchesEntirely","extractCountryCallingCode","extractCountryCallingCodeFromInternationalNumberWithoutPlusSign","extractNationalNumber","stripIddPrefix","getCountryByCallingCode","MAX_INPUT_STRING_LENGTH","PHONE_NUMBER_START_PATTERN","RegExp","AFTER_PHONE_NUMBER_END_PATTERN","USE_NON_GEOGRAPHIC_COUNTRY_CODE","parse","text","options","metadata","defaultCountry","hasCountry","v2","Error","parseInput","extract","formattedPhoneNumber","number","ext","error","parsePhoneNumber","defaultCallingCode","country","nationalNumber","countryCallingCode","carrierCode","hasSelectedNumberingPlan","length","phoneNumber","valid","extended","nationalNumberPattern","result","possible","possibleLengths","phone","extractFormattedPhoneNumber","throwOnError","startsAt","search","slice","replace","indexOf","withExtensionStripped","selectNumberingPlan","isNonGeographicCallingCode","exactCountry"],"mappings":"AAAA;AACA;AACA;AACA;AAEA,SACCA,YADD,EAECC,UAFD,EAGCC,kBAHD,EAICC,kBAJD,QAKO,aALP;AAOA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,mBAAP,IAA8BC,wBAA9B,QAA8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AoB;AACnBY,QAAAA,OAAO,GAAGZ,cAAV;AACA,OAFD,MAEO;AACN;AACA,YAAIL,+BAAJ,EAAqC;AACpC,cAAII,QAAQ,CAACoC,0BAAT,CAAoCxB,kBAApC,CAAJ,EAA6D;AAC5DC,YAAAA,OAAO,GAAG,KAAV;AACA;AACD;AACD;;AACDE,MAAAA,kBAAkB,GAAGH,kBAAkB,IAAI9B,qBAAqB,CAACmB,cAAD,EAAiBD,QAAQ,CAACA,QAA1B,CAAhE;AACA,KAbI,MAcA,OAAO,EAAP;;AAEL,MAAI,CAACQ,MAAL,EAAa;AACZ,WAAO;AAAEO,MAAAA,kBAAkB,EAAlBA;AAAF,KAAP;AACA;;AAlCA,8BAuCG1B,qBAAqB,CACxBR,0BAA0B,CAAC2B,MAAD,CADF,EAExBR,QAFwB,CAvCxB;AAAA,MAqCAc,cArCA,yBAqCAA,cArCA;AAAA,MAsCAE,WAtCA,yBAsCAA,WAtCA,EA4CD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMqB,YAAY,GAAG9C,uBAAuB,CAACwB,kBAAD,EAAqBD,cAArB,EAAqCd,QAArC,CAA5C;;AACA,MAAIqC,YAAJ,EAAkB;AACjBxB,IAAAA,OAAO,GAAGwB,YAAV;AACA;;AACA,QAAIA,YAAY,KAAK,KAArB,EAA4B,CAC3B;AACA;AACA;AACA,KAJD,MAIO;AACNrC,MAAAA,QAAQ,CAACa,OAAT,CAAiBA,OAAjB;AACA;AACD;;AAED,SAAO;AACNA,IAAAA,OAAO,EAAPA,OADM;AAENE,IAAAA,kBAAkB,EAAlBA,kBAFM;AAGND,IAAAA,cAAc,EAAdA,cAHM;AAINE,IAAAA,WAAW,EAAXA;AAJM,GAAP;AAMA","sourcesContent":["// This is a port of Google Android `libphonenumber`'s\r\n// `phonenumberutil.js` of December 31th, 2018.\r\n//\r\n// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js\r\n\r\nimport {\r\n\tVALID_DIGITS,\r\n\tPLUS_CHARS,\r\n\tMIN_LENGTH_FOR_NSN,\r\n\tMAX_LENGTH_FOR_NSN\r\n} from './constants'\r\n\r\nimport ParseError from './ParseError'\r\nimport Metadata from './metadata'\r\nimport isViablePhoneNumber, { isViablePhoneNumberStart } from './helpers/isViablePhoneNumber'\r\nimport extractExtension from './helpers/extension/extractExtension'\r\nimport parseIncompletePhoneNumber from './parseIncompletePhoneNumber'\r\nimport getCountryCallingCode from './getCountryCallingCode'\r\nimport { isPossibleNumber } from './isPossibleNumber_'\r\nimport { parseRFC3966 } from './helpers/RFC3966'\r\nimport PhoneNumber from './PhoneNumber'\r\nimport matchesEntirely from './helpers/matchesEntirely'\r\nimport extractCountryCallingCode from './helpers/extractCountryCallingCode'\r\nimport extractCountryCallingCodeFromInternationalNumberWithoutPlusSign from './helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign'\r\nimport extractNationalNumber from './helpers/extractNationalNumber'\r\nimport stripIddPrefix from './helpers/stripIddPrefix'\r\nimport getCountryByCallingCode from './helpers/getCountryByCallingCode'\r\n\r\n// We don't allow input strings for parsing to be longer than 250 chars.\r\n// This prevents malicious input from consuming CPU.\r\nconst MAX_INPUT_STRING_LENGTH = 250\r\n\r\n// This consists of the plus symbol, digits, and arabic-indic digits.\r\nconst PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']')\r\n\r\n// Regular expression of trailing characters that we want to remove.\r\n// A trailing `#` is sometimes used when writing phone numbers with extensions in US.\r\n// Example: \"+1 (645) 123 1234-910#\" number has extension \"910\".\r\nconst AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$')\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\n// Examples:\r\n//\r\n// ```js\r\n// parse('8 (800) 555-35-35', 'RU')\r\n// parse('8 (800) 555-35-35', 'RU', metadata)\r\n// parse('8 (800) 555-35-35', { country: { default: 'RU' } })\r\n// parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)\r\n// parse('+7 800 555 35 35')\r\n// parse('+7 800 555 35 35', metadata)\r\n// ```\r\n//\r\nexport default function parse(text, options, metadata) {\r\n\t// If assigning the `{}` default value is moved to the arguments above,\r\n\t// code coverage would decrease for some weird reason.\r\n\toptions = options || {}\r\n\r\n\tmetadata = new Metadata(metadata)\r\n\r\n\t// Validate `defaultCountry`.\r\n\tif (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('INVALID_COUNTRY')\r\n\t\t}\r\n\t\tthrow new Error(`Unknown country: ${options.defaultCountry}`)\r\n\t}\r\n\r\n\t// Parse the phone number.\r\n\tconst { number: formattedPhoneNumber, ext, error } = parseInput(text, options.v2, options.extract)\r\n\r\n\t// If the phone number is not viable then return nothing.\r\n\tif (!formattedPhoneNumber) {\r\n\t\tif (options.v2) {\r\n\t\t\tif (error === 'TOO_SHORT') {\r\n\t\t\t\tthrow new ParseError('TOO_SHORT')\r\n\t\t\t}\r\n\t\t\tthrow new ParseError('NOT_A_NUMBER')\r\n\t\t}\r\n\t\treturn {}\r\n\t}\r\n\r\n\tconst {\r\n\t\tcountry,\r\n\t\tnationalNumber,\r\n\t\tcountryCallingCode,\r\n\t\tcarrierCode\r\n\t} = parsePhoneNumber(\r\n\t\tformattedPhoneNumber,\r\n\t\toptions.defaultCountry,\r\n\t\toptions.defaultCallingCode,\r\n\t\tmetadata\r\n\t)\r\n\r\n\tif (!metadata.hasSelectedNumberingPlan()) {\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('INVALID_COUNTRY')\r\n\t\t}\r\n\t\treturn {}\r\n\t}\r\n\r\n\t// Validate national (significant) number length.\r\n\tif (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {\r\n\t\t// Won't throw here because the regexp already demands length > 1.\r\n\t\t/* istanbul ignore if */\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('TOO_SHORT')\r\n\t\t}\r\n\t\t// Google's demo just throws an error in this case.\r\n\t\treturn {}\r\n\t}\r\n\r\n\t// Validate national (significant) number length.\r\n\t//\r\n\t// A sidenote:\r\n\t//\r\n\t// They say that sometimes national (significant) numbers\r\n\t// can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).\r\n\t// https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36\r\n\t// Such numbers will just be discarded.\r\n\t//\r\n\tif (nationalNumber.length > MAX_LENGTH_FOR_NSN) {\r\n\t\tif (options.v2) {\r\n\t\t\tthrow new ParseError('TOO_LONG')\r\n\t\t}\r\n\t\t// Google's demo just throws an error in this case.\r\n\t\treturn {}\r\n\t}\r\n\r\n\tif (options.v2) {\r\n\t\tconst phoneNumber = new PhoneNumber(\r\n\t\t\tcountryCallingCode,\r\n\t\t\tnationalNumber,\r\n\t\t\tmetadata.metadata\r\n\t\t)\r\n\t\tif (country) {\r\n\t\t\tphoneNumber.country = country\r\n\t\t}\r\n\t\tif (carrierCode) {\r\n\t\t\tphoneNumber.carrierCode = carrierCode\r\n\t\t}\r\n\t\tif (ext) {\r\n\t\t\tphoneNumber.ext = ext\r\n\t\t}\r\n\t\treturn phoneNumber\r\n\t}\r\n\r\n\t// Check if national phone number pattern matches the number.\r\n\t// National number pattern is different for each country,\r\n\t// even for those ones which are part of the \"NANPA\" group.\r\n\tconst valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ?\r\n\t\tmatchesEntirely(nationalNumber, metadata.nationalNumberPattern()) :\r\n\t\tfalse\r\n\r\n\tif (!options.extended) {\r\n\t\treturn valid ? result(country, nationalNumber, ext) : {}\r\n\t}\r\n\r\n\t// isInternational: countryCallingCode !== undefined\r\n\r\n\treturn {\r\n\t\tcountry,\r\n\t\tcountryCallingCode,\r\n\t\tcarrierCode,\r\n\t\tvalid,\r\n\t\tpossible: valid ? true : (\r\n\t\t\toptions.extended === true &&\r\n\t\t\tmetadata.possibleLengths() &&\r\n\t\t\tisPossibleNumber(nationalNumber, metadata) ? true : false\r\n\t\t),\r\n\t\tphone: nationalNumber,\r\n\t\text\r\n\t}\r\n}\r\n\r\n/**\r\n * Extracts a formatted phone number from text.\r\n * Doesn't guarantee that the extracted phone number\r\n * is a valid phone number (for example, doesn't validate its length).\r\n * @param {string} text\r\n * @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.\r\n * @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.\r\n * @return {string}\r\n * @example\r\n * // Returns \"(213) 373-4253\".\r\n * extractFormattedPhoneNumber(\"Call (213) 373-4253 for assistance.\")\r\n */\r\nfunction extractFormattedPhoneNumber(text, extract, throwOnError) {\r\n\tif (!text) {\r\n\t\treturn\r\n\t}\r\n\tif (text.length > MAX_INPUT_STRING_LENGTH) {\r\n\t\tif (throwOnError) {\r\n\t\t\tthrow new ParseError('TOO_LONG')\r\n\t\t}\r\n\t\treturn\r\n\t}\r\n\tif (extract === false) {\r\n\t\treturn text\r\n\t}\r\n\t// Attempt to extract a possible number from the string passed in\r\n\tconst startsAt = text.search(PHONE_NUMBER_START_PATTERN)\r\n\tif (startsAt < 0) {\r\n\t\treturn\r\n\t}\r\n\treturn text\r\n\t\t// Trim everything to the left of the phone number\r\n\t\t.slice(startsAt)\r\n\t\t// Remove trailing non-numerical characters\r\n\t\t.replace(AFTER_PHONE_NUMBER_END_PATTERN, '')\r\n}\r\n\r\n/**\r\n * @param {string} text - Input.\r\n * @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.\r\n * @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.\r\n * @return {object} `{ ?number, ?ext }`.\r\n */\r\nfunction parseInput(text, v2, extract) {\r\n\t// Parse RFC 3966 phone number URI.\r\n\tif (text && text.indexOf('tel:') === 0) {\r\n\t\treturn parseRFC3966(text)\r\n\t}\r\n\tlet number = extractFormattedPhoneNumber(text, extract, v2)\r\n\t// If the phone number is not viable, then abort.\r\n\tif (!number) {\r\n\t\treturn {}\r\n\t}\r\n\tif (!isViablePhoneNumber(number)) {\r\n\t\tif (isViablePhoneNumberStart(number)) {\r\n\t\t\treturn { error: 'TOO_SHORT' }\r\n\t\t}\r\n\t\treturn {}\r\n\t}\r\n\t// Attempt to parse extension first, since it doesn't require region-specific\r\n\t// data and we want to have the non-normalised number here.\r\n\tconst withExtensionStripped = extractExtension(number)\r\n\tif (withExtensionStripped.ext) {\r\n\t\treturn withExtensionStripped\r\n\t}\r\n\treturn { number }\r\n}\r\n\r\n/**\r\n * Creates `parse()` result object.\r\n */\r\nfunction result(country, nationalNumber, ext) {\r\n\tconst result = {\r\n\t\tcountry,\r\n\t\tphone: nationalNumber\r\n\t}\r\n\tif (ext) {\r\n\t\tresult.ext = ext\r\n\t}\r\n\treturn result\r\n}\r\n\r\n/**\r\n * Parses a viable phone number.\r\n * @param {string} formattedPhoneNumber — Example: \"(213) 373-4253\".\r\n * @param {string} [defaultCountry]\r\n * @param {string} [defaultCallingCode]\r\n * @param {Metadata} metadata\r\n * @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.\r\n */\r\nfunction parsePhoneNumber(\r\n\tformattedPhoneNumber,\r\n\tdefaultCountry,\r\n\tdefaultCallingCode,\r\n\tmetadata\r\n) {\r\n\t// Extract calling code from phone number.\r\n\tlet { countryCallingCode, number } = extractCountryCallingCode(\r\n\t\tparseIncompletePhoneNumber(formattedPhoneNumber),\r\n\t\tdefaultCountry,\r\n\t\tdefaultCallingCode,\r\n\t\tmetadata.metadata\r\n\t)\r\n\r\n\t// Choose a country by `countryCallingCode`.\r\n\tlet country\r\n\tif (countryCallingCode) {\r\n\t\tmetadata.selectNumberingPlan(countryCallingCode)\r\n\t}\r\n\t// If `formattedPhoneNumber` is in \"national\" format\r\n\t// then `number` is defined and `countryCallingCode` isn't.\r\n\telse if (number && (defaultCountry || defaultCallingCode)) {\r\n\t\tmetadata.selectNumberingPlan(defaultCountry, defaultCallingCode)\r\n\t\tif (defaultCountry) {\r\n\t\t\tcountry = defaultCountry\r\n\t\t} else {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (metadata.isNonGeographicCallingCode(defaultCallingCode)) {\r\n\t\t\t\t\tcountry = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tcountryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata)\r\n\t}\r\n\telse return {}\r\n\r\n\tif (!number) {\r\n\t\treturn { countryCallingCode }\r\n\t}\r\n\r\n\tconst {\r\n\t\tnationalNumber,\r\n\t\tcarrierCode\r\n\t} = extractNationalNumber(\r\n\t\tparseIncompletePhoneNumber(number),\r\n\t\tmetadata\r\n\t)\r\n\r\n\t// Sometimes there are several countries\r\n\t// corresponding to the same country phone code\r\n\t// (e.g. NANPA countries all having `1` country phone code).\r\n\t// Therefore, to reliably determine the exact country,\r\n\t// national (significant) number should have been parsed first.\r\n\t//\r\n\t// When `metadata.json` is generated, all \"ambiguous\" country phone codes\r\n\t// get their countries populated with the full set of\r\n\t// \"phone number type\" regular expressions.\r\n\t//\r\n\tconst exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata)\r\n\tif (exactCountry) {\r\n\t\tcountry = exactCountry\r\n\t\t/* istanbul ignore if */\r\n\t\tif (exactCountry === '001') {\r\n\t\t\t// Can't happen with `USE_NON_GEOGRAPHIC_COUNTRY_CODE` being `false`.\r\n\t\t\t// If `USE_NON_GEOGRAPHIC_COUNTRY_CODE` is set to `true` for some reason,\r\n\t\t\t// then remove the \"istanbul ignore if\".\r\n\t\t} else {\r\n\t\t\tmetadata.country(country)\r\n\t\t}\r\n\t}\r\n\r\n\treturn {\r\n\t\tcountry,\r\n\t\tcountryCallingCode,\r\n\t\tnationalNumber,\r\n\t\tcarrierCode\r\n\t}\r\n}"],"file":"parse_.js"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
5
|
+
import { normalizeArguments } from './parsePhoneNumber';
|
|
6
|
+
import parsePhoneNumber from './parsePhoneNumber_';
|
|
7
|
+
import ParseError from './ParseError';
|
|
8
|
+
import Metadata from './metadata';
|
|
9
|
+
import checkNumberLength from './helpers/checkNumberLength';
|
|
10
|
+
export default function validatePhoneNumberLength() {
|
|
11
|
+
var _normalizeArguments = normalizeArguments(arguments),
|
|
12
|
+
text = _normalizeArguments.text,
|
|
13
|
+
options = _normalizeArguments.options,
|
|
14
|
+
metadata = _normalizeArguments.metadata;
|
|
15
|
+
|
|
16
|
+
options = _objectSpread({}, options, {
|
|
17
|
+
extract: false // Parse phone number.
|
|
18
|
+
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
var phoneNumber = parsePhoneNumber(text, options, metadata);
|
|
23
|
+
metadata = new Metadata(metadata);
|
|
24
|
+
metadata.selectNumberingPlan(phoneNumber.countryCallingCode);
|
|
25
|
+
var result = checkNumberLength(phoneNumber.nationalNumber, metadata);
|
|
26
|
+
|
|
27
|
+
if (result !== 'IS_POSSIBLE') {
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
/* istanbul ignore else */
|
|
32
|
+
if (error instanceof ParseError) {
|
|
33
|
+
return error.message;
|
|
34
|
+
} else {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=validatePhoneNumberLength.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../source/validatePhoneNumberLength.js"],"names":["normalizeArguments","parsePhoneNumber","ParseError","Metadata","checkNumberLength","validatePhoneNumberLength","arguments","text","options","metadata","extract","phoneNumber","selectNumberingPlan","countryCallingCode","result","nationalNumber","error","message"],"mappings":";;;;AAAA,SAASA,kBAAT,QAAmC,oBAAnC;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,iBAAP,MAA8B,6BAA9B;AAEA,eAAe,SAASC,yBAAT,GAAqC;AAAA,4BACjBL,kBAAkB,CAACM,SAAD,CADD;AAAA,MAC7CC,IAD6C,uBAC7CA,IAD6C;AAAA,MACvCC,OADuC,uBACvCA,OADuC;AAAA,MAC9BC,QAD8B,uBAC9BA,QAD8B;;AAEnDD,EAAAA,OAAO,qBACHA,OADG;AAENE,IAAAA,OAAO,EAAE,KAFH,CAKP;;AALO,IAAP;;AAMA,MAAI;AACH,QAAMC,WAAW,GAAGV,gBAAgB,CAACM,IAAD,EAAOC,OAAP,EAAgBC,QAAhB,CAApC;AACAA,IAAAA,QAAQ,GAAG,IAAIN,QAAJ,CAAaM,QAAb,CAAX;AACAA,IAAAA,QAAQ,CAACG,mBAAT,CAA6BD,WAAW,CAACE,kBAAzC;AACA,QAAMC,MAAM,GAAGV,iBAAiB,CAACO,WAAW,CAACI,cAAb,EAA6BN,QAA7B,CAAhC;;AACA,QAAIK,MAAM,KAAK,aAAf,EAA8B;AAC7B,aAAOA,MAAP;AACA;AACD,GARD,CAQE,OAAOE,KAAP,EAAc;AACf;AACA,QAAIA,KAAK,YAAYd,UAArB,EAAiC;AAChC,aAAOc,KAAK,CAACC,OAAb;AACA,KAFD,MAEO;AACN,YAAMD,KAAN;AACA;AACD;AACD","sourcesContent":["import { normalizeArguments } from './parsePhoneNumber'\r\nimport parsePhoneNumber from './parsePhoneNumber_'\r\nimport ParseError from './ParseError'\r\nimport Metadata from './metadata'\r\nimport checkNumberLength from './helpers/checkNumberLength'\r\n\r\nexport default function validatePhoneNumberLength() {\r\n\tlet { text, options, metadata } = normalizeArguments(arguments)\r\n\toptions = {\r\n\t\t...options,\r\n\t\textract: false\r\n\t}\r\n\r\n\t// Parse phone number.\r\n\ttry {\r\n\t\tconst phoneNumber = parsePhoneNumber(text, options, metadata)\r\n\t\tmetadata = new Metadata(metadata)\r\n\t\tmetadata.selectNumberingPlan(phoneNumber.countryCallingCode)\r\n\t\tconst result = checkNumberLength(phoneNumber.nationalNumber, metadata)\r\n\t\tif (result !== 'IS_POSSIBLE') {\r\n\t\t\treturn result\r\n\t\t}\r\n\t} catch (error) {\r\n\t\t/* istanbul ignore else */\r\n\t\tif (error instanceof ParseError) {\r\n\t\t\treturn error.message\r\n\t\t} else {\r\n\t\t\tthrow error\r\n\t\t}\r\n\t}\r\n}"],"file":"validatePhoneNumberLength.js"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _validatePhoneNumberLength from './validatePhoneNumberLength';
|
|
2
|
+
import metadata from '../metadata.min.json';
|
|
3
|
+
|
|
4
|
+
function validatePhoneNumberLength() {
|
|
5
|
+
for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
6
|
+
parameters[_key] = arguments[_key];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
parameters.push(metadata);
|
|
10
|
+
return _validatePhoneNumberLength.apply(this, parameters);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe('validatePhoneNumberLength', function () {
|
|
14
|
+
it('should detect whether a phone number length is valid', function () {
|
|
15
|
+
// Not a phone number.
|
|
16
|
+
validatePhoneNumberLength('+').should.equal('NOT_A_NUMBER');
|
|
17
|
+
validatePhoneNumberLength('abcde').should.equal('NOT_A_NUMBER'); // No country supplied for a national number.
|
|
18
|
+
|
|
19
|
+
validatePhoneNumberLength('123').should.equal('INVALID_COUNTRY'); // Too short while the number is not considered "viable"
|
|
20
|
+
// by Google's `libphonenumber`.
|
|
21
|
+
|
|
22
|
+
validatePhoneNumberLength('2', 'US').should.equal('TOO_SHORT');
|
|
23
|
+
validatePhoneNumberLength('+1', 'US').should.equal('TOO_SHORT');
|
|
24
|
+
validatePhoneNumberLength('+12', 'US').should.equal('TOO_SHORT'); // Test national (significant) number length.
|
|
25
|
+
|
|
26
|
+
validatePhoneNumberLength('444 1 44', 'TR').should.equal('TOO_SHORT');
|
|
27
|
+
expect(validatePhoneNumberLength('444 1 444', 'TR')).to.be.undefined;
|
|
28
|
+
validatePhoneNumberLength('444 1 4444', 'TR').should.equal('INVALID_LENGTH');
|
|
29
|
+
validatePhoneNumberLength('444 1 4444444444', 'TR').should.equal('TOO_LONG');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=validatePhoneNumberLength.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../source/validatePhoneNumberLength.test.js"],"names":["_validatePhoneNumberLength","metadata","validatePhoneNumberLength","parameters","push","apply","describe","it","should","equal","expect","to","be","undefined"],"mappings":"AAAA,OAAOA,0BAAP,MAAuC,6BAAvC;AACA,OAAOC,QAAP,MAAqB,sBAArB;;AAEA,SAASC,yBAAT,GAAkD;AAAA,oCAAZC,UAAY;AAAZA,IAAAA,UAAY;AAAA;;AACjDA,EAAAA,UAAU,CAACC,IAAX,CAAgBH,QAAhB;AACA,SAAOD,0BAA0B,CAACK,KAA3B,CAAiC,IAAjC,EAAuCF,UAAvC,CAAP;AACA;;AAEDG,QAAQ,CAAC,2BAAD,EAA8B,YAAM;AAC3CC,EAAAA,EAAE,CAAC,sDAAD,EAAyD,YAAM;AAChE;AACAL,IAAAA,yBAAyB,CAAC,GAAD,CAAzB,CAA+BM,MAA/B,CAAsCC,KAAtC,CAA4C,cAA5C;AACAP,IAAAA,yBAAyB,CAAC,OAAD,CAAzB,CAAmCM,MAAnC,CAA0CC,KAA1C,CAAgD,cAAhD,EAHgE,CAKhE;;AACAP,IAAAA,yBAAyB,CAAC,KAAD,CAAzB,CAAiCM,MAAjC,CAAwCC,KAAxC,CAA8C,iBAA9C,EANgE,CAQhE;AACA;;AACAP,IAAAA,yBAAyB,CAAC,GAAD,EAAM,IAAN,CAAzB,CAAqCM,MAArC,CAA4CC,KAA5C,CAAkD,WAAlD;AACAP,IAAAA,yBAAyB,CAAC,IAAD,EAAO,IAAP,CAAzB,CAAsCM,MAAtC,CAA6CC,KAA7C,CAAmD,WAAnD;AACAP,IAAAA,yBAAyB,CAAC,KAAD,EAAQ,IAAR,CAAzB,CAAuCM,MAAvC,CAA8CC,KAA9C,CAAoD,WAApD,EAZgE,CAchE;;AACAP,IAAAA,yBAAyB,CAAC,UAAD,EAAa,IAAb,CAAzB,CAA4CM,MAA5C,CAAmDC,KAAnD,CAAyD,WAAzD;AACAC,IAAAA,MAAM,CAACR,yBAAyB,CAAC,WAAD,EAAc,IAAd,CAA1B,CAAN,CAAqDS,EAArD,CAAwDC,EAAxD,CAA2DC,SAA3D;AACAX,IAAAA,yBAAyB,CAAC,YAAD,EAAe,IAAf,CAAzB,CAA8CM,MAA9C,CAAqDC,KAArD,CAA2D,gBAA3D;AACAP,IAAAA,yBAAyB,CAAC,kBAAD,EAAqB,IAArB,CAAzB,CAAoDM,MAApD,CAA2DC,KAA3D,CAAiE,UAAjE;AACA,GAnBC,CAAF;AAoBA,CArBO,CAAR","sourcesContent":["import _validatePhoneNumberLength from './validatePhoneNumberLength'\r\nimport metadata from '../metadata.min.json'\r\n\r\nfunction validatePhoneNumberLength(...parameters) {\r\n\tparameters.push(metadata)\r\n\treturn _validatePhoneNumberLength.apply(this, parameters)\r\n}\r\n\r\ndescribe('validatePhoneNumberLength', () => {\r\n\tit('should detect whether a phone number length is valid', () => {\r\n\t\t// Not a phone number.\r\n\t\tvalidatePhoneNumberLength('+').should.equal('NOT_A_NUMBER')\r\n\t\tvalidatePhoneNumberLength('abcde').should.equal('NOT_A_NUMBER')\r\n\r\n\t\t// No country supplied for a national number.\r\n\t\tvalidatePhoneNumberLength('123').should.equal('INVALID_COUNTRY')\r\n\r\n\t\t// Too short while the number is not considered \"viable\"\r\n\t\t// by Google's `libphonenumber`.\r\n\t\tvalidatePhoneNumberLength('2', 'US').should.equal('TOO_SHORT')\r\n\t\tvalidatePhoneNumberLength('+1', 'US').should.equal('TOO_SHORT')\r\n\t\tvalidatePhoneNumberLength('+12', 'US').should.equal('TOO_SHORT')\r\n\r\n\t\t// Test national (significant) number length.\r\n\t\tvalidatePhoneNumberLength('444 1 44', 'TR').should.equal('TOO_SHORT')\r\n\t\texpect(validatePhoneNumberLength('444 1 444', 'TR')).to.be.undefined\r\n\t\tvalidatePhoneNumberLength('444 1 4444', 'TR').should.equal('INVALID_LENGTH')\r\n\t\tvalidatePhoneNumberLength('444 1 4444444444', 'TR').should.equal('TOO_LONG')\r\n\t})\r\n})"],"file":"validatePhoneNumberLength.test.js"}
|
package/index.common.js
CHANGED
|
@@ -26,6 +26,10 @@ exports.ParseError = min.ParseError
|
|
|
26
26
|
exports.parsePhoneNumber = min.parsePhoneNumberWithError
|
|
27
27
|
exports.parsePhoneNumberWithError = min.parsePhoneNumberWithError
|
|
28
28
|
|
|
29
|
+
exports.isValidPhoneNumber = min.isValidPhoneNumber
|
|
30
|
+
exports.isPossiblePhoneNumber = min.isPossiblePhoneNumber
|
|
31
|
+
exports.validatePhoneNumberLength = min.validatePhoneNumberLength
|
|
32
|
+
|
|
29
33
|
// `parse()` and `parseNumber()` functions are deprecated.
|
|
30
34
|
var parse_ = require('./build/parse').default
|
|
31
35
|
exports.parse = function parse() {
|