diff --git a/PhoneNumber.js b/PhoneNumber.js index 7636874..5e127c0 100644 --- a/PhoneNumber.js +++ b/PhoneNumber.js @@ -286,8 +286,9 @@ var PhoneNumber = (function (dataBase) { // Remove formating characters and whitespace. number = PhoneNumberNormalizer.Normalize(number); - // If there is no defaultRegion, we can't parse international access codes. - if (!defaultRegion && number[0] !== '+') + //@e can't parse international access codes f there is no defaultRegion + // or the defaultRegion is the global region. + if ((!defaultRegion || defaultRegion === '001') && number[0] !== '+') return null; // Detect and strip leading '+'. diff --git a/test.js b/test.js index ec2777a..956b06e 100644 --- a/test.js +++ b/test.js @@ -252,14 +252,14 @@ CantParse("911", "US"); // China mobile number with a 0 in it Format("15955042864", "CN", "15955042864", "CN", "0159 5504 2864", "+86 159 5504 2864"); -// Formate international 001 numbers without country code. -Format("883510000000094", "001", "510000000094", "001", "510 000 000 094", "+883 510 000 000 094"); -Format("+883510000000094", "001", "510000000094", "001", "510 000 000 094", "+883 510 000 000 094"); -Format("883510000000094", "FR", "510000000094", "001", "510 000 000 094", "+883 510 000 000 094"); +// Testing international region numbers. +CantParse("883510000000091", "001"); +Format("+883510000000092", "001", "510000000092", "001", "510 000 000 092", "+883 510 000 000 092"); +Format("883510000000093", "FR", "510000000093", "001", "510 000 000 093", "+883 510 000 000 093"); Format("+883510000000094", "FR", "510000000094", "001", "510 000 000 094", "+883 510 000 000 094"); -Format("883510000000094", "US", "510000000094", "001", "510 000 000 094", "+883 510 000 000 094"); -Format("+883510000000094", "US", "510000000094", "001", "510 000 000 094", "+883 510 000 000 094"); -Format("979510000012", "001", "510000012", "001", "5 1000 0012", "+979 5 1000 0012"); +Format("883510000000095", "US", "510000000095", "001", "510 000 000 095", "+883 510 000 000 095"); +Format("+883510000000096", "US", "510000000096", "001", "510 000 000 096", "+883 510 000 000 096"); +CantParse("979510000012", "001"); Format("+979510000012", "001", "510000012", "001", "5 1000 0012", "+979 5 1000 0012"); // Test normalizing numbers. Only 0-9,#* are valid in a phone number.