Fixed errors

This commit is contained in:
Michael Rowley 2021-12-30 23:27:09 +00:00
parent 5673c11c5d
commit 0c5c599150

View file

@ -36,14 +36,14 @@ class HTMLToText extends Operation {
// TODO: Add blacklisted tags via args.
// TODO: Extract from HTML comments.
let output = "";
const blacklistedTags = [ "script", "style" ];
const tagRegex = /<\w+>[\s?!\-_().,\/#{}*"£$%^&;:a-z]*/gis;
const blacklistedTags = ["script", "style"];
const tagRegex = /<\w+>[\s?!\-_().,/#{}*"£$%^&;:a-z]*/gis;
const tagMatches = input.match(tagRegex);
tagMatches.forEach((iterativeMatch) => {
const closingTagOffset = iterativeMatch.indexOf('>');
const closingTagOffset = iterativeMatch.indexOf(">");
const tag = iterativeMatch.substring(1, closingTagOffset);
for (let i = 0; i < blacklistedTags.length; i++) {
if (tag == blacklistedTags[i]) {
if (tag === blacklistedTags[i]) {
return; // This is why a forEach(...) loop couldn't be used for this nested one.
}
}