Skip to content

Commit 36db917

Browse files
authored
Add "()" when string.match() is executed in js (#3769)
* Fix regex logic * Simplify code * Fix variable name * Add case insensitive option for regexp
1 parent 4246175 commit 36db917

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

javascript/i18n/phonenumbers/phonenumberutil.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4759,8 +4759,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.canBeInternationallyDialled =
47594759
*/
47604760
i18n.phonenumbers.PhoneNumberUtil.matchesEntirely = function(regex, str) {
47614761
/** @type {Array.<string>} */
4762-
var matchedGroups = (typeof regex == 'string') ?
4763-
str.match('^(?:' + regex + ')$') : str.match(regex);
4762+
var matchedGroups = str.match(new RegExp('^(?:' + (typeof regex == 'string' ? regex : regex.source) + ')$', 'i'));
47644763
if (matchedGroups && matchedGroups[0].length == str.length) {
47654764
return true;
47664765
}

0 commit comments

Comments
 (0)