From 519f962ee069881776d03e7b67055d1e9cc569fd Mon Sep 17 00:00:00 2001
From: igor <igor.markin@vereign.com>
Date: Thu, 17 Dec 2020 18:48:06 +0300
Subject: [PATCH] Use url-parse in plainnormalizer and fix imports

---
 src/HTMLNormalizer/strategies/common.ts | 3 ++-
 src/PlainNormalizer/PlainNormalizer.ts  | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/HTMLNormalizer/strategies/common.ts b/src/HTMLNormalizer/strategies/common.ts
index 67ae8d2..26fc83f 100644
--- a/src/HTMLNormalizer/strategies/common.ts
+++ b/src/HTMLNormalizer/strategies/common.ts
@@ -1,4 +1,5 @@
-import URL from "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";
 
diff --git a/src/PlainNormalizer/PlainNormalizer.ts b/src/PlainNormalizer/PlainNormalizer.ts
index b31666c..83c6c43 100644
--- a/src/PlainNormalizer/PlainNormalizer.ts
+++ b/src/PlainNormalizer/PlainNormalizer.ts
@@ -1,3 +1,6 @@
+// this is a Node module. require is a must to work across different envs
+const URL = require("url-parse");
+
 import { removeSpacesAndLinebreaks } from "../utils";
 
 export const normalizePlainPart = (text: string): string => {
@@ -14,8 +17,8 @@ const patchOutlookSafelinksWrappers = (text: string) => {
 
   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