Skip to content
Snippets Groups Projects
Commit 0f9c6f30 authored by Igor Markin's avatar Igor Markin
Browse files

Add build

parent 519f962e
Branches
Tags
1 merge request!13Use url parse
"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);
......
"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}>`);
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment