Bug 858339 - PhoneNumberJS: Fix colombian phone numbers without the leading +. r=bent
authorGregor Wagner <anygregor@gmail.com>
Thu, 04 Apr 2013 17:40:04 -0700
changeset 127732 db1838b652938002554bd64bbf993b23e0621da3
parent 127731 1576f07a1d8b72e27079a884840b6787f1d82890
child 127733 ca34eba9c8b630ede0c9eb62fa7717c3df7c06a8
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
bugs858339
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 858339 - PhoneNumberJS: Fix colombian phone numbers without the leading +. r=bent
dom/phonenumberutils/PhoneNumber.jsm
dom/phonenumberutils/tests/test_phonenumber.xul
--- a/dom/phonenumberutils/PhoneNumber.jsm
+++ b/dom/phonenumberutils/PhoneNumber.jsm
@@ -358,27 +358,27 @@ this.PhoneNumber = (function (dataBase) 
           (ret = ParseNationalNumber(number.substr(nationalPrefix.length), md))) {
         return ret;
       }
     }
     ret = ParseNationalNumber(number, md)
     if (ret)
       return ret;
 
-    // If the number matches the possible numbers of the current region,
-    // return it as a possible number.
-    if (md.possiblePattern.test(number))
-      return new NationalNumber(md, number);
-
     // Now lets see if maybe its an international number after all, but
     // without '+' or the international prefix.
     ret = ParseInternationalNumber(number)
     if (ret)
       return ret;
 
+    // If the number matches the possible numbers of the current region,
+    // return it as a possible number.
+    if (md.possiblePattern.test(number))
+      return new NationalNumber(md, number);
+
     // We couldn't parse the number at all.
     return null;
   }
 
   function IsPlainPhoneNumber(number) {
     if (typeof number !== 'string') {
       return false;
     }
--- a/dom/phonenumberutils/tests/test_phonenumber.xul
+++ b/dom/phonenumberutils/tests/test_phonenumber.xul
@@ -278,16 +278,19 @@ Format("0577-555-555", "IT", "0577555555
 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");
 
+// Colombian international number without the leading "+"
+Format("5712234567", "CO", "12234567", "CO", "(1) 2234567", "+57 1 2234567");
+
 // 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");