From 36db91716b625945e2590b781c6a1c257080e5c8 Mon Sep 17 00:00:00 2001 From: SG-Kang <101150768+SG-Kang@users.noreply.github.com> Date: Mon, 23 Dec 2024 22:37:17 +0900 Subject: [PATCH] Add "()" when string.match() is executed in js (#3769) * Fix regex logic * Simplify code * Fix variable name * Add case insensitive option for regexp --- 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 d530dae5e4..c64cd1f922 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); + var matchedGroups = str.match(new RegExp('^(?:' + (typeof regex == 'string' ? regex : regex.source) + ')$', 'i')); if (matchedGroups && matchedGroups[0].length == str.length) { return true; }