From 715154033600da9bb658239196325074389853d3 Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Wed, 12 Nov 2025 11:07:08 +0000 Subject: [PATCH 1/7] 000 Short Code incorrectly formatting for E164 and National. --- .../i18n/phonenumbers/PhoneNumberUtil.java | 18 ++++++++++++--- .../phonenumbers/PhoneNumberUtilTest.java | 9 +++++++- .../i18n/phonenumbers/phonenumberutil.js | 22 ++++++++++++++----- .../i18n/phonenumbers/phonenumberutil_test.js | 7 ++++++ 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 6d8004f18..0622d3760 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -1289,10 +1289,22 @@ public class PhoneNumberUtil { public String format(PhoneNumber number, PhoneNumberFormat numberFormat) { if (number.getNationalNumber() == 0) { // Unparseable numbers that kept their raw input just use that. - // This is the only case where a number can be formatted as E164 without a - // leading '+' symbol (but the original number wasn't parseable anyway). String rawInput = number.getRawInput(); - if (rawInput.length() > 0 || !number.hasCountryCode()) { + if (rawInput.length() > 0 && number.hasCountryCode()) { + String rawInputwithoutCountryCode = rawInput; + // The country calling code must be stripped from the rawInput if it starts with '+'. + // This is necessary because the national formatting function will add the country calling + // code by default." + if (rawInput.startsWith("+")) { + int countryCallingCode = String.valueOf(number.getCountryCode()).length(); + rawInputwithoutCountryCode = rawInput.substring(countryCallingCode + 1); + } + if (numberFormat == PhoneNumberFormat.NATIONAL) { + return rawInputwithoutCountryCode; + } else { + return "+" + number.getCountryCode() + rawInputwithoutCountryCode; + } + } else if (rawInput.length() > 0 || !number.hasCountryCode()) { return rawInput; } } diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 2b9345c4c..18a3c81eb 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -108,7 +108,10 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { new PhoneNumber().setCountryCode(1).setNationalNumber(8002530000L); private static final PhoneNumber US_SPOOF = new PhoneNumber().setCountryCode(1).setNationalNumber(0L); - private static final PhoneNumber US_SPOOF_WITH_RAW_INPUT = + private static final PhoneNumber AU_SHORT_CODE_WITH_RAW_INPUT = + new PhoneNumber().setCountryCode(61).setNationalNumber(0L) + .setRawInput("000"); + private static final PhoneNumber US_SPOOF_WITH_RAW_INPUT = new PhoneNumber().setCountryCode(1).setNationalNumber(0L) .setRawInput("000-000-0000"); private static final PhoneNumber UZ_FIXED_LINE = @@ -507,6 +510,10 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { assertEquals("000-000-0000", phoneUtil.format(US_SPOOF_WITH_RAW_INPUT, PhoneNumberFormat.NATIONAL)); assertEquals("0", phoneUtil.format(US_SPOOF, PhoneNumberFormat.NATIONAL)); + assertEquals("+61000", phoneUtil.format(AU_SHORT_CODE_WITH_RAW_INPUT, PhoneNumberFormat.E164)); + PhoneNumber number = PhoneNumber.getDefaultInstance(); + assertThat(phoneUtil.format(number, PhoneNumberFormat.NATIONAL)).isEmpty(); + } public void testFormatBSNumber() { diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index 8812d3aa4..0df9b6117 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -1781,15 +1781,25 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.hasValidCountryCallingCode_ = i18n.phonenumbers.PhoneNumberUtil.prototype.format = function(number, numberFormat) { - if (number.getNationalNumber() == 0 && number.hasRawInput()) { + if (number.getNationalNumber() == 0 ) { // Unparseable numbers that kept their raw input just use that. - // This is the only case where a number can be formatted as E164 without a - // leading '+' symbol (but the original number wasn't parseable anyway). - // TODO: Consider removing the 'if' above so that unparseable strings - // without raw input format to the empty string instead of "+00" /** @type {string} */ var rawInput = number.getRawInputOrDefault(); - if (rawInput.length > 0) { + if (rawInput.length > 0 && number.hasCountryCode()) { + /** @type {string} */ + let rawInputwithoutCountryCode = rawInput; + //The country calling code must be stripped from the rawInput if it starts with '+'. + //This is necessary because the national formatting function will add the country calling code by default." + if (rawInput.startsWith('+')) { + const countryCallingCode = String.valueOf(number.getCountryCode()).length(); + rawInputwithoutCountryCode = rawInput.substring(countryCallingCode + 1); + } + if (numberFormat == i18n.phonenumbers.PhoneNumberFormat.NATIONAL) { + return rawInputwithoutCountryCode; + } else { + return '+' + number.getCountryCode() + rawInputwithoutCountryCode; + } + } else if (rawInput.length > 0 || !number.hasCountryCode()) { return rawInput; } } diff --git a/javascript/i18n/phonenumbers/phonenumberutil_test.js b/javascript/i18n/phonenumbers/phonenumberutil_test.js index 4070dd08a..a26bea618 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil_test.js +++ b/javascript/i18n/phonenumbers/phonenumberutil_test.js @@ -225,6 +225,11 @@ US_SPOOF_WITH_RAW_INPUT.setCountryCode(1); US_SPOOF_WITH_RAW_INPUT.setNationalNumber(0); US_SPOOF_WITH_RAW_INPUT.setRawInput('000-000-0000'); +/** @type {!i18n.phonenumbers.PhoneNumber} */ +var AU_SHORT_CODE_WITH_RAW_INPUT = new i18n.phonenumbers.PhoneNumber(); +AU_SHORT_CODE_WITH_RAW_INPUT.setCountryCode(61); +AU_SHORT_CODE_WITH_RAW_INPUT.setNationalNumber(0); +AU_SHORT_CODE_WITH_RAW_INPUT.setRawInput('000'); /** @type {!i18n.phonenumbers.PhoneNumber} */ var UZ_FIXED_LINE = new i18n.phonenumbers.PhoneNumber(); @@ -674,6 +679,8 @@ function testFormatUSNumber() { assertEquals( '000-000-0000', phoneUtil.format(US_SPOOF_WITH_RAW_INPUT, PNF.NATIONAL)); assertEquals('0', phoneUtil.format(US_SPOOF, PNF.NATIONAL)); + assertEquals('+61000', phoneUtil.format(AU_SHORT_CODE_WITH_RAW_INPUT, PNF.E164)); + assertEquals('', phoneUtil.format(new i18n.phonenumbers.PhoneNumber(), PNF.NATIONAL)); } function testFormatBSNumber() { From f363d6f925dd0cabd0804323b35ae4009f429371 Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:59:10 +0530 Subject: [PATCH 2/7] Update PhoneNumberUtilTest.java --- .../test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 18a3c81eb..75d3e2d61 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -511,9 +511,6 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { phoneUtil.format(US_SPOOF_WITH_RAW_INPUT, PhoneNumberFormat.NATIONAL)); assertEquals("0", phoneUtil.format(US_SPOOF, PhoneNumberFormat.NATIONAL)); assertEquals("+61000", phoneUtil.format(AU_SHORT_CODE_WITH_RAW_INPUT, PhoneNumberFormat.E164)); - PhoneNumber number = PhoneNumber.getDefaultInstance(); - assertThat(phoneUtil.format(number, PhoneNumberFormat.NATIONAL)).isEmpty(); - } public void testFormatBSNumber() { From c3625a576aba0686240b525fa2a21357c4be5486 Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Fri, 14 Nov 2025 03:33:45 +0000 Subject: [PATCH 3/7] Fixed, 000 Short Code formatting for E164 --- .../i18n/phonenumbers/PhoneNumberUtil.java | 26 +++++++---------- .../phonenumbers/PhoneNumberUtilTest.java | 17 ++++++++--- .../i18n/phonenumbers/phonenumberutil.js | 29 ++++++++----------- .../i18n/phonenumbers/phonenumberutil_test.js | 19 +++++++----- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 0622d3760..22727d2a9 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -1288,22 +1288,18 @@ public class PhoneNumberUtil { */ public String format(PhoneNumber number, PhoneNumberFormat numberFormat) { if (number.getNationalNumber() == 0) { - // Unparseable numbers that kept their raw input just use that. + // Unparseable numbers that kept their raw input just use that, unless default country was + // specified and the format is E164. In that case, we prepend the raw input with the country + // code String rawInput = number.getRawInput(); - if (rawInput.length() > 0 && number.hasCountryCode()) { - String rawInputwithoutCountryCode = rawInput; - // The country calling code must be stripped from the rawInput if it starts with '+'. - // This is necessary because the national formatting function will add the country calling - // code by default." - if (rawInput.startsWith("+")) { - int countryCallingCode = String.valueOf(number.getCountryCode()).length(); - rawInputwithoutCountryCode = rawInput.substring(countryCallingCode + 1); - } - if (numberFormat == PhoneNumberFormat.NATIONAL) { - return rawInputwithoutCountryCode; - } else { - return "+" + number.getCountryCode() + rawInputwithoutCountryCode; - } + if (rawInput.length() > 0 + && number.hasCountryCode() + && number.getCountryCodeSource() == CountryCodeSource.FROM_DEFAULT_COUNTRY + && numberFormat == PhoneNumberFormat.E164) { + int countryCallingCode = number.getCountryCode(); + StringBuilder formattedNumber = new StringBuilder(rawInput); + prefixNumberWithCountryCallingCode(countryCallingCode, numberFormat, formattedNumber); + return formattedNumber.toString(); } else if (rawInput.length() > 0 || !number.hasCountryCode()) { return rawInput; } diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 75d3e2d61..0bfbfb859 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -108,9 +108,6 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { new PhoneNumber().setCountryCode(1).setNationalNumber(8002530000L); private static final PhoneNumber US_SPOOF = new PhoneNumber().setCountryCode(1).setNationalNumber(0L); - private static final PhoneNumber AU_SHORT_CODE_WITH_RAW_INPUT = - new PhoneNumber().setCountryCode(61).setNationalNumber(0L) - .setRawInput("000"); private static final PhoneNumber US_SPOOF_WITH_RAW_INPUT = new PhoneNumber().setCountryCode(1).setNationalNumber(0L) .setRawInput("000-000-0000"); @@ -510,7 +507,19 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { assertEquals("000-000-0000", phoneUtil.format(US_SPOOF_WITH_RAW_INPUT, PhoneNumberFormat.NATIONAL)); assertEquals("0", phoneUtil.format(US_SPOOF, PhoneNumberFormat.NATIONAL)); - assertEquals("+61000", phoneUtil.format(AU_SHORT_CODE_WITH_RAW_INPUT, PhoneNumberFormat.E164)); + } + + public void testFormatAUShortCodeNumber() throws Exception { + PhoneNumber auShortCodeNumber = phoneUtil.parse("000", RegionCode.AU); + assertEquals("+61000", phoneUtil.format(auShortCodeNumber, PhoneNumberFormat.E164)); + + PhoneNumber pgShortCodeNumber = + PhoneNumber.newBuilder() + .setCountryCode(675) + .setNationalNumber(0L) + .setRawInput("+675000") + .build(); + assertEquals("+675000", phoneUtil.format(pgShortCodeNumber, PhoneNumberFormat.E164)); } public void testFormatBSNumber() { diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index 0df9b6117..3db9dbc10 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -1781,24 +1781,19 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.hasValidCountryCallingCode_ = i18n.phonenumbers.PhoneNumberUtil.prototype.format = function(number, numberFormat) { - if (number.getNationalNumber() == 0 ) { - // Unparseable numbers that kept their raw input just use that. + if (number.getNationalNumber() == 0 && number.hasRawInput()) { + // Unparseable numbers that kept their raw input just use that, unless + // default country was specified and the format is E164. In that case, we + // prepend the raw input with the country code. /** @type {string} */ - var rawInput = number.getRawInputOrDefault(); - if (rawInput.length > 0 && number.hasCountryCode()) { - /** @type {string} */ - let rawInputwithoutCountryCode = rawInput; - //The country calling code must be stripped from the rawInput if it starts with '+'. - //This is necessary because the national formatting function will add the country calling code by default." - if (rawInput.startsWith('+')) { - const countryCallingCode = String.valueOf(number.getCountryCode()).length(); - rawInputwithoutCountryCode = rawInput.substring(countryCallingCode + 1); - } - if (numberFormat == i18n.phonenumbers.PhoneNumberFormat.NATIONAL) { - return rawInputwithoutCountryCode; - } else { - return '+' + number.getCountryCode() + rawInputwithoutCountryCode; - } + const rawInput = number.getRawInputOrDefault(); + if (rawInput.length > 0 && number.hasCountryCode() + && number.getCountryCodeSource() == i18n.phonenumbers.PhoneNumber.CountryCodeSource.FROM_DEFAULT_COUNTRY + && numberFormat == i18n.phonenumbers.PhoneNumberFormat.E164) { + const countryCallingCode = number.getCountryCode(); + let formattedNumber = new StringBuilder(rawInput); + this.prefixNumberWithCountryCallingCode(countryCallingCode, numberFormat, formattedNumber); + return formattedNumber.toString(); } else if (rawInput.length > 0 || !number.hasCountryCode()) { return rawInput; } diff --git a/javascript/i18n/phonenumbers/phonenumberutil_test.js b/javascript/i18n/phonenumbers/phonenumberutil_test.js index a26bea618..f146d7be5 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil_test.js +++ b/javascript/i18n/phonenumbers/phonenumberutil_test.js @@ -225,11 +225,6 @@ US_SPOOF_WITH_RAW_INPUT.setCountryCode(1); US_SPOOF_WITH_RAW_INPUT.setNationalNumber(0); US_SPOOF_WITH_RAW_INPUT.setRawInput('000-000-0000'); -/** @type {!i18n.phonenumbers.PhoneNumber} */ -var AU_SHORT_CODE_WITH_RAW_INPUT = new i18n.phonenumbers.PhoneNumber(); -AU_SHORT_CODE_WITH_RAW_INPUT.setCountryCode(61); -AU_SHORT_CODE_WITH_RAW_INPUT.setNationalNumber(0); -AU_SHORT_CODE_WITH_RAW_INPUT.setRawInput('000'); /** @type {!i18n.phonenumbers.PhoneNumber} */ var UZ_FIXED_LINE = new i18n.phonenumbers.PhoneNumber(); @@ -679,8 +674,18 @@ function testFormatUSNumber() { assertEquals( '000-000-0000', phoneUtil.format(US_SPOOF_WITH_RAW_INPUT, PNF.NATIONAL)); assertEquals('0', phoneUtil.format(US_SPOOF, PNF.NATIONAL)); - assertEquals('+61000', phoneUtil.format(AU_SHORT_CODE_WITH_RAW_INPUT, PNF.E164)); - assertEquals('', phoneUtil.format(new i18n.phonenumbers.PhoneNumber(), PNF.NATIONAL)); +} + +function testFormatAUShortCodeNumber() { + const auShortCodeNumber = phoneUtil.parse("000", RegionCode.AU); + const PNF = i18n.phonenumbers.PhoneNumberFormat; + assertEquals('+61000', phoneUtil.format(auShortCodeNumber, PNF.E164)); + + const pgShortCodeNumber = new i18n.phonenumbers.PhoneNumber(); + pgShortCodeNumber.setCountryCode(675); + pgShortCodeNumber.setNationalNumber(0); + pgShortCodeNumber.setRawInput('+675000'); + assertEquals('+675000', phoneUtil.format(pgShortCodeNumber, PNF.E164)); } function testFormatBSNumber() { From 4679403f1916e17f53de4f8190251e9ff527a091 Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Fri, 14 Nov 2025 03:36:13 +0000 Subject: [PATCH 4/7] removed spaces --- .../com/google/i18n/phonenumbers/PhoneNumberUtilTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 0bfbfb859..207b045b6 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -108,7 +108,7 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { new PhoneNumber().setCountryCode(1).setNationalNumber(8002530000L); private static final PhoneNumber US_SPOOF = new PhoneNumber().setCountryCode(1).setNationalNumber(0L); - private static final PhoneNumber US_SPOOF_WITH_RAW_INPUT = + private static final PhoneNumber US_SPOOF_WITH_RAW_INPUT = new PhoneNumber().setCountryCode(1).setNationalNumber(0L) .setRawInput("000-000-0000"); private static final PhoneNumber UZ_FIXED_LINE = @@ -508,7 +508,7 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { phoneUtil.format(US_SPOOF_WITH_RAW_INPUT, PhoneNumberFormat.NATIONAL)); assertEquals("0", phoneUtil.format(US_SPOOF, PhoneNumberFormat.NATIONAL)); } - + public void testFormatAUShortCodeNumber() throws Exception { PhoneNumber auShortCodeNumber = phoneUtil.parse("000", RegionCode.AU); assertEquals("+61000", phoneUtil.format(auShortCodeNumber, PhoneNumberFormat.E164)); From b676b70f20c80c658973beac0a3f4d3b21e0eefa Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Fri, 14 Nov 2025 03:51:48 +0000 Subject: [PATCH 5/7] fix testcase failure --- .../google/i18n/phonenumbers/PhoneNumberUtilTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 207b045b6..4da210ec1 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -512,13 +512,10 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { public void testFormatAUShortCodeNumber() throws Exception { PhoneNumber auShortCodeNumber = phoneUtil.parse("000", RegionCode.AU); assertEquals("+61000", phoneUtil.format(auShortCodeNumber, PhoneNumberFormat.E164)); - + PhoneNumber pgShortCodeNumber = - PhoneNumber.newBuilder() - .setCountryCode(675) - .setNationalNumber(0L) - .setRawInput("+675000") - .build(); + new PhoneNumber().setCountryCode(675).setNationalNumber(0L) + .setRawInput("+675000"); assertEquals("+675000", phoneUtil.format(pgShortCodeNumber, PhoneNumberFormat.E164)); } From 822a091a2f6491cc16e4a6ebf5bcf28118600a3f Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Fri, 14 Nov 2025 06:36:31 +0000 Subject: [PATCH 6/7] updated phonenumberutil.js file --- javascript/i18n/phonenumbers/phonenumberutil.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index 3db9dbc10..5153c1517 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -1791,9 +1791,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.format = && number.getCountryCodeSource() == i18n.phonenumbers.PhoneNumber.CountryCodeSource.FROM_DEFAULT_COUNTRY && numberFormat == i18n.phonenumbers.PhoneNumberFormat.E164) { const countryCallingCode = number.getCountryCode(); - let formattedNumber = new StringBuilder(rawInput); - this.prefixNumberWithCountryCallingCode(countryCallingCode, numberFormat, formattedNumber); - return formattedNumber.toString(); + let formattedNumber =rawInput; + return this.prefixNumberWithCountryCallingCode_(countryCallingCode, numberFormat, formattedNumber,''); } else if (rawInput.length > 0 || !number.hasCountryCode()) { return rawInput; } From 97ecea6769f2a67aea403aed9e0d8f47d3f9c265 Mon Sep 17 00:00:00 2001 From: mandlil <138015259+mandlil@users.noreply.github.com> Date: Fri, 14 Nov 2025 06:38:34 +0000 Subject: [PATCH 7/7] update phonenumberutil.js file --- javascript/i18n/phonenumbers/phonenumberutil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index 5153c1517..db90566a4 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -1790,7 +1790,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.format = if (rawInput.length > 0 && number.hasCountryCode() && number.getCountryCodeSource() == i18n.phonenumbers.PhoneNumber.CountryCodeSource.FROM_DEFAULT_COUNTRY && numberFormat == i18n.phonenumbers.PhoneNumberFormat.E164) { - const countryCallingCode = number.getCountryCode(); + const countryCallingCode = number.getCountryCodeOrDefault(); let formattedNumber =rawInput; return this.prefixNumberWithCountryCallingCode_(countryCallingCode, numberFormat, formattedNumber,''); } else if (rawInput.length > 0 || !number.hasCountryCode()) {