Skip to content

Commit ef121d4

Browse files
committed
Use regex.test() when we want to check for a Boolean. (#29969)
1 parent 8731ad9 commit ef121d4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

build/vnu-jar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ childProcess.exec('java -version', (error, stdout, stderr) => {
1818
return
1919
}
2020

21-
const is32bitJava = !stderr.match(/64-Bit/)
21+
const is32bitJava = !/64-Bit/.test(stderr)
2222

2323
// vnu-jar accepts multiple ignores joined with a `|`.
2424
// Also note that the ignores are regular expressions.

js/src/tools/sanitizer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function allowedAttribute(attr, allowedAttributeList) {
7171

7272
if (allowedAttributeList.indexOf(attrName) !== -1) {
7373
if (uriAttrs.indexOf(attrName) !== -1) {
74-
return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
74+
return SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue)
7575
}
7676

7777
return true
@@ -80,8 +80,8 @@ function allowedAttribute(attr, allowedAttributeList) {
8080
const regExp = allowedAttributeList.filter((attrRegex) => attrRegex instanceof RegExp)
8181

8282
// Check if a regular expression validates the attribute.
83-
for (let i = 0, l = regExp.length; i < l; i++) {
84-
if (attrName.match(regExp[i])) {
83+
for (let i = 0, len = regExp.length; i < len; i++) {
84+
if (regExp[i].test(attrName)) {
8585
return true
8686
}
8787
}

0 commit comments

Comments
 (0)