Bug 858330 - PhoneNumberJS: Fix chilean mobile numbers. r=bent
authorGregor Wagner <anygregor@gmail.com>
Thu, 04 Apr 2013 17:39:57 -0700
changeset 127731 1576f07a1d8b72e27079a884840b6787f1d82890
parent 127730 9ba6b7c64335c7457684f40ee99d3909b47f7110
child 127732 db1838b652938002554bd64bbf993b23e0621da3
push id24512
push userryanvm@gmail.com
push dateFri, 05 Apr 2013 20:13:49 +0000
treeherdermozilla-central@139b6ba547fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs858330
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 858330 - PhoneNumberJS: Fix chilean mobile numbers. r=bent
dom/phonenumberutils/PhoneNumber.jsm
dom/phonenumberutils/tests/test_phonenumber.xul
--- a/dom/phonenumberutils/PhoneNumber.jsm
+++ b/dom/phonenumberutils/PhoneNumber.jsm
@@ -341,17 +341,17 @@ this.PhoneNumber = (function (dataBase) 
     }
 
     // This is not an international number. See if its a national one for
     // the current region. National numbers can start with the national
     // prefix, or without.
     if (md.nationalPrefixForParsing) {
       // Some regions have specific national prefix parse rules. Apply those.
       var withoutPrefix = number.replace(md.nationalPrefixForParsing,
-                                         md.nationalPrefixTransformRule);
+                                         md.nationalPrefixTransformRule || '');
       ret = ParseNationalNumber(withoutPrefix, md)
       if (ret)
         return ret;
     } else {
       // If there is no specific national prefix rule, just strip off the
       // national prefix from the beginning of the number (if there is one).
       var nationalPrefix = md.nationalPrefix;
       if (nationalPrefix && number.indexOf(nationalPrefix) == 0 &&
--- a/dom/phonenumberutils/tests/test_phonenumber.xul
+++ b/dom/phonenumberutils/tests/test_phonenumber.xul
@@ -272,16 +272,22 @@ Format("451491934", "DE", "451491934", "
 Format("0451491934", "DE", "451491934", "DE", "0451 491934", "+49 451 491934");
 
 // Numbers in italy keep the leading 0 in the city code when dialing internationally.
 Format("0577-555-555", "IT", "0577555555", "IT", "05 7755 5555", "+39 05 7755 5555");
 
 // Telefonica tests
 Format("612123123", "ES", "612123123", "ES", "612 12 31 23", "+34 612 12 31 23");
 
+// Chile mobile number from a landline
+Format("0997654321", "CL", "997654321", "CL", "(99) 765 4321", "+56 99 765 4321");
+
+// Chile mobile number from another mobile number
+Format("997654321", "CL", "997654321", "CL", "(99) 765 4321", "+56 99 765 4321");
+
 // Dialing 911 in the US. This is not a national number.
 CantParse("911", "US");
 
 // Test normalizing numbers. Only 0-9,#* are valid in a phone number.
 Normalize("+ABC # * , 9 _ 1 _0", "+222#*,910");
 Normalize("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "22233344455566677778889999");
 Normalize("abcdefghijklmnopqrstuvwxyz", "22233344455566677778889999");