1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-28 14:29:07 +02:00

Switch to String.includes()

This commit is contained in:
XhmikosR
2020-05-02 16:43:13 +03:00
parent 470e99ed5f
commit b9f7668cf6
5 changed files with 8 additions and 10 deletions

View File

@@ -35,8 +35,8 @@ const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|vid
const allowedAttribute = (attr, allowedAttributeList) => {
const attrName = attr.nodeName.toLowerCase()
if (allowedAttributeList.indexOf(attrName) !== -1) {
if (uriAttrs.indexOf(attrName) !== -1) {
if (allowedAttributeList.includes(attrName)) {
if (uriAttrs.includes(attrName)) {
return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
}
@@ -107,7 +107,7 @@ export function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
const el = elements[i]
const elName = el.nodeName.toLowerCase()
if (allowlistKeys.indexOf(elName) === -1) {
if (!allowlistKeys.includes(elName)) {
el.parentNode.removeChild(el)
continue