From 0f9c6f30bc3cbb2293f6a2d70a99b7a482eb7497 Mon Sep 17 00:00:00 2001 From: igor <igor.markin@vereign.com> Date: Thu, 17 Dec 2020 18:48:32 +0300 Subject: [PATCH] Add build --- dist/HTMLNormalizer/strategies/common.js | 7 ++++--- dist/PlainNormalizer/PlainNormalizer.js | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dist/HTMLNormalizer/strategies/common.js b/dist/HTMLNormalizer/strategies/common.js index c2869fc..738dc47 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 afa2a4d..33762f5 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}>`); }); } -- GitLab