diff options
Diffstat (limited to 'webAO/encoding.ts')
| -rw-r--r-- | webAO/encoding.ts | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/webAO/encoding.ts b/webAO/encoding.ts index 37f064a9..1c380f7d 100644 --- a/webAO/encoding.ts +++ b/webAO/encoding.ts @@ -21,36 +21,3 @@ export function unescapeChat(estring: string): string { .replaceAll("<percent>", "%") .replaceAll("<dollar>", "$"); } - -/** - * Escapes a string to be HTML-safe. - * - * XXX: This is unnecessary if we use `createTextNode` instead! - * @param {string} unsafe an unsanitized string - */ -export function safeTags(unsafe: string): string { - if (unsafe) { - return unsafe.replaceAll(">", ">").replaceAll("<", "<"); - } - return ""; -} - -/** - * Decodes text on client side. - * @param {string} estring the string to be decoded - */ -export function decodeChat(estring: string): string { - // Source: https://stackoverflow.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode - return estring.replace(/\\u([\d\w]{1,})/gi, (match, group) => - String.fromCharCode(parseInt(group, 16)), - ); -} - -/** - * XXX: a nasty hack made by gameboyprinter. - * @param {string} msg chat message to prepare for display - */ -export function prepChat(msg: string): string { - // TODO: make this less awful - return safeTags(unescapeChat(decodeChat(msg))); -} |
