mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
The API base is a fixed constant; fetchFromUrl only attaches the bearer token to betterseqta.org and accounts.betterseqta.org.
20 lines
545 B
TypeScript
20 lines
545 B
TypeScript
import DOMPurify from "dompurify";
|
|
|
|
export default function stringToHTML(str: string, styles = false) {
|
|
const parser = new DOMParser();
|
|
|
|
str = DOMPurify.sanitize(str, {
|
|
ALLOWED_URI_REGEXP:
|
|
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|chrome-extension):|\/|#|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,
|
|
});
|
|
|
|
const doc = parser.parseFromString(str, "text/html");
|
|
|
|
if (styles) {
|
|
doc.body.style.cssText =
|
|
"height: auto; overflow: scroll; margin: 0px; background: var(--background-primary);";
|
|
}
|
|
|
|
return doc.body;
|
|
}
|