Skip to content

Commit

Permalink
Add "()" when string.match() is executed in js (#3769)
Browse files Browse the repository at this point in the history
* Fix regex logic

* Simplify code

* Fix variable name

* Add case insensitive option for regexp
  • Loading branch information
SG-Kang authored Dec 23, 2024
1 parent 4246175 commit 36db917
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions javascript/i18n/phonenumbers/phonenumberutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -4759,8 +4759,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.canBeInternationallyDialled =
*/
i18n.phonenumbers.PhoneNumberUtil.matchesEntirely = function(regex, str) {
/** @type {Array.<string>} */
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;
}
Expand Down

0 comments on commit 36db917

Please sign in to comment.