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

Add build

parent 078b87ed
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,25 @@ const amendNodes = (document) => {
anchor.setAttribute("href", url.query["url"]);
}
}
/**
* Unwind Gmail "googleusercontent" wrappers
*/
const images = document.getElementsByTagName("img");
for (const image of images) {
let url;
try {
url = new URL(image.getAttribute("src"));
}
catch (e) {
url = null;
}
if (url && url.host.includes("googleusercontent.com")) {
const originalUrl = url.hash.slice(1, url.hash.length);
if (originalUrl) {
image.setAttribute("src", originalUrl);
}
}
}
};
exports.amendNodes = amendNodes;
/**
......
......@@ -7,8 +7,9 @@ const utils_1 = require("../utils");
const normalizePlainPart = (text) => {
text = removeListBullets(text);
text = utils_1.removeSpacesAndLinebreaks(text);
text = removeQRCodes(text);
text = patchOutlookSafelinksWrappers(text);
return removeQRCodes(text);
return text;
};
exports.normalizePlainPart = normalizePlainPart;
const patchOutlookSafelinksWrappers = (text) => {
......@@ -24,8 +25,8 @@ const patchOutlookSafelinksWrappers = (text) => {
};
const removeQRCodes = (s) => {
return s
.replace(/\[(image:)*qrcode.png]\s*<https:\/\/[\w./?=\-&]+>/g, "")
.replace(/<https:\/\/[\w./?=\-&]+>\s*\[(image: )*qrcode.png]/g, "");
.replace(/\[(image:)*qrcode.png]\s*<https:\/\/.+?>/g, "")
.replace(/<https:\/\/.+?>\s*\[(image: )*qrcode.png]/g, "");
};
const removeListBullets = (s) => {
return s.replace("\n[o§]\n+/g", "");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment