Newer
Older
import { removeSpacesAndLinebreaks } from "../utils";
export const normalizePlainPart = (text: string): string => {
text = patchOutlookSafelinksWrappers(text);
const patchOutlookSafelinksWrappers = (text: string) => {
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");
text = text.replace(link, `<${originalUrl}>`);
});
}
return text;
};
const removeQRCodes = (s: string): string => {
return s
.replace(/\[(image:)*qrcode.png]\s*<https:\/\/[\w./?=\-&]+>/g, "")
.replace(/<https:\/\/[\w./?=\-&]+>\s*\[(image: )*qrcode.png]/g, "");