Bug 858330 - PhoneNumberJS: Fix chilean mobile numbers. r=bent, a=tef+
authorGregor Wagner <anygregor@gmail.com>
Thu, 04 Apr 2013 17:39:57 -0700
changeset 118987 3f96276c678a3381c5b5c215316d0a10e5188aeb
parent 118986 aa6f30aa779cca11c329c1eb1d98d56340f2ee51
child 118988 2ff11a06ea815a200bab538890e305130fae1333
push id635
push userryanvm@gmail.com
push dateMon, 08 Apr 2013 12:54:53 +0000
reviewersbent, tef
bugs858330
milestone18.0
Bug 858330 - PhoneNumberJS: Fix chilean mobile numbers. r=bent, a=tef+
dom/phonenumberutils/PhoneNumber.jsm
dom/phonenumberutils/tests/test_phonenumber.xul
--- a/dom/phonenumberutils/PhoneNumber.jsm
+++ b/dom/phonenumberutils/PhoneNumber.jsm
@@ -339,17 +339,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 || '');
       if (ret = ParseNationalNumber(withoutPrefix, md))
         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 &&
           (ret = ParseNationalNumber(number.substr(nationalPrefix.length), md))) {
--- 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");