Browse Source

Add "()" when string.match() is executed in js (#3769)

* Fix regex logic

* Simplify code

* Fix variable name

* Add case insensitive option for regexp
pull/3772/head
SG-Kang 12 months ago
committed by GitHub
parent
commit
36db91716b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 2 deletions
  1. +1
    -2
      javascript/i18n/phonenumbers/phonenumberutil.js

+ 1
- 2
javascript/i18n/phonenumbers/phonenumberutil.js View File

@ -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;
}


Loading…
Cancel
Save