Use regex.test() when we want to check for a Boolean. (#29969)
This commit is contained in:
parent
a7945d4501
commit
9c2b9ac74d
4 changed files with 6 additions and 8 deletions
|
|
@ -39,7 +39,7 @@ const allowedAttribute = (attr, allowedAttributeList) => {
|
|||
|
||||
if (allowedAttributeList.indexOf(attrName) !== -1) {
|
||||
if (uriAttrs.indexOf(attrName) !== -1) {
|
||||
return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
|
||||
return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue)
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
@ -48,8 +48,8 @@ const allowedAttribute = (attr, allowedAttributeList) => {
|
|||
const regExp = allowedAttributeList.filter(attrRegex => attrRegex instanceof RegExp)
|
||||
|
||||
// Check if a regular expression validates the attribute.
|
||||
for (let i = 0, l = regExp.length; i < l; i++) {
|
||||
if (attrName.match(regExp[i])) {
|
||||
for (let i = 0, len = regExp.length; i < len; i++) {
|
||||
if (regExp[i].test(attrName)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue