mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
refactor: modernise old code, fix svelte warnings and redo title bar badge
This commit is contained in:
68 files changed
+785
-2152
No files matched your search
@@ -1,17 +1,5 @@
|
||||
import DOMPurify from "dompurify";
|
||||
|
||||
/**
|
||||
* Converts an HTML string into a DOM element, with sanitization and optional styling.
|
||||
*
|
||||
* This function first sanitizes the input HTML string using DOMPurify to prevent XSS attacks.
|
||||
* The sanitization process allows only safe URI schemes in links and media.
|
||||
* Then, it parses the sanitized string into an HTML document and returns its body.
|
||||
* Optionally, it can apply predefined CSS styles to the body element.
|
||||
*
|
||||
* @param {string} str The HTML string to convert.
|
||||
* @param {boolean} [styles=false] Whether to apply predefined styles to the document body.
|
||||
* @returns {HTMLElement} The body element of the parsed and sanitized HTML document.
|
||||
*/
|
||||
export default function stringToHTML(str: string, styles = false) {
|
||||
const parser = new DOMParser();
|
||||
|
||||
|
||||
Reference in new issue
Block a user