From 7666d15d80d84c43bbec7a2eec64231d798e84a8 Mon Sep 17 00:00:00 2001 From: SG-Kang <101150768+SG-Kang@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:17:21 +0900 Subject: [PATCH 1/4] Fix regex logic --- 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 d530dae5e4..ba427426ab 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -4760,7 +4760,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.canBeInternationallyDialled = i18n.phonenumbers.PhoneNumberUtil.matchesEntirely = function(regex, str) { /** @type {Array.} */ var matchedGroups = (typeof regex == 'string') ? - str.match('^(?:' + regex + ')$') : str.match(regex); + str.match('^(?:' + regex + ')$') : str.match("^(?:" + regex.source + ")$"); if (matchedGroups && matchedGroups[0].length == str.length) { return true; } From 6c37d573bb30247e430bfb217076f48594b82b8c Mon Sep 17 00:00:00 2001 From: SG-Kang <101150768+SG-Kang@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:36:45 +0900 Subject: [PATCH 2/4] Simplify code --- javascript/i18n/phonenumbers/phonenumberutil.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index ba427426ab..bcb1197864 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -4759,8 +4759,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.canBeInternationallyDialled = */ i18n.phonenumbers.PhoneNumberUtil.matchesEntirely = function(regex, str) { /** @type {Array.} */ - var matchedGroups = (typeof regex == 'string') ? - str.match('^(?:' + regex + ')$') : str.match("^(?:" + regex.source + ")$"); + var matchedGroups = b2.match('^(?:' + (typeof a2 == 'string' ? a2 : a2.source) + ')$') if (matchedGroups && matchedGroups[0].length == str.length) { return true; } From f92e36864e5a84c79a1f905bf37042f61d188fa2 Mon Sep 17 00:00:00 2001 From: SG-Kang <101150768+SG-Kang@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:38:18 +0900 Subject: [PATCH 3/4] Fix variable name --- 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 bcb1197864..eebc5c4360 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -4759,7 +4759,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.canBeInternationallyDialled = */ i18n.phonenumbers.PhoneNumberUtil.matchesEntirely = function(regex, str) { /** @type {Array.} */ - var matchedGroups = b2.match('^(?:' + (typeof a2 == 'string' ? a2 : a2.source) + ')$') + var matchedGroups = str.match('^(?:' + (typeof regex == 'string' ? regex : regex.source) + ')$') if (matchedGroups && matchedGroups[0].length == str.length) { return true; } From 83873036dac4f470e8a7321aa7536240b1c72725 Mon Sep 17 00:00:00 2001 From: SG-Kang <101150768+SG-Kang@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:42:59 +0900 Subject: [PATCH 4/4] Add case insensitive option for regexp --- 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 eebc5c4360..c64cd1f922 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -4759,7 +4759,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.canBeInternationallyDialled = */ i18n.phonenumbers.PhoneNumberUtil.matchesEntirely = function(regex, str) { /** @type {Array.} */ - var matchedGroups = str.match('^(?:' + (typeof regex == 'string' ? regex : regex.source) + ')$') + var matchedGroups = str.match(new RegExp('^(?:' + (typeof regex == 'string' ? regex : regex.source) + ')$', 'i')); if (matchedGroups && matchedGroups[0].length == str.length) { return true; }