diff --git a/dist/HTMLNormalizer/strategies/common.js b/dist/HTMLNormalizer/strategies/common.js index c2869fcc14e30b566074665420047532ba63b86e..738dc47f61c13b4520fe731bc0855883e0196cb9 100644 --- a/dist/HTMLNormalizer/strategies/common.js +++ b/dist/HTMLNormalizer/strategies/common.js @@ -1,7 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cloneAnchorFromPane = exports.pruneElement = exports.amendNodes = exports.ATTRIBUTES_TO_KEEP = exports.ELEMENT_TYPES_TO_REMOVE = void 0; -const url_parse_1 = require("url-parse"); +// this is a Node module. require is a must to work across different envs +const URL = require("url-parse"); const DUMMY_QR_CODE_ID = "dummyQrCode"; exports.ELEMENT_TYPES_TO_REMOVE = { br: true, @@ -24,7 +25,7 @@ const amendNodes = (document) => { */ const anchors = document.getElementsByTagName("a"); for (const anchor of anchors) { - const url = new url_parse_1.default(anchor.getAttribute("href"), true); + const url = new URL(anchor.getAttribute("href"), true); if (url.host.includes("safelinks.protection.outlook.com")) { anchor.setAttribute("href", url.query["url"]); } @@ -53,7 +54,7 @@ const pruneElement = (element) => { exports.pruneElement = pruneElement; const cloneAnchorFromPane = (a, pane) => { try { - const url = new url_parse_1.default(a.getAttribute("href")); + const url = new URL(a.getAttribute("href")); // If this is external url if (url.host && url.protocol) { pane.parentNode.insertBefore(a.cloneNode(false), pane); diff --git a/dist/PlainNormalizer/PlainNormalizer.js b/dist/PlainNormalizer/PlainNormalizer.js index afa2a4d0f31a45ac4bfc1f78efdd697e93255da4..33762f5561a843e399d40551c2d23a3809d42208 100644 --- a/dist/PlainNormalizer/PlainNormalizer.js +++ b/dist/PlainNormalizer/PlainNormalizer.js @@ -1,6 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizePlainPart = void 0; +// this is a Node module. require is a must to work across different envs +const URL = require("url-parse"); const utils_1 = require("../utils"); const normalizePlainPart = (text) => { text = removeListBullets(text); @@ -13,8 +15,8 @@ const patchOutlookSafelinksWrappers = (text) => { const links = text.match(/<https:.+?(safelinks\.protection\.outlook\.com).+?>/g); if (links) { links.forEach((link) => { - const url = new URL(link.slice(1, link.length - 1)); - const originalUrl = url.searchParams.get("url"); + const url = new URL(link.slice(1, link.length - 1), true); + const originalUrl = url.query["url"]; text = text.replace(link, `<${originalUrl}>`); }); }