From 8c7b3aa3728853b0eeec11bac66d7ffdd961775d Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 8 Jan 2023 20:37:02 +0100 Subject: regex slow and cringe --- webAO/encoding.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'webAO/encoding.ts') diff --git a/webAO/encoding.ts b/webAO/encoding.ts index 54770d0..2d1f66f 100644 --- a/webAO/encoding.ts +++ b/webAO/encoding.ts @@ -4,10 +4,10 @@ */ export function escapeChat(estring: string): string { return estring - .replace(/#/g, '') - .replace(/&/g, '') - .replace(/%/g, '') - .replace(/\$/g, ''); + .replace('#', '') + .replace('&', '') + .replace('%', '') + .replace('$', ''); } /** @@ -16,10 +16,10 @@ export function escapeChat(estring: string): string { */ export function unescapeChat(estring: string): string { return estring - .replace(//g, '#') - .replace(//g, '&') - .replace(//g, '%') - .replace(//g, '$'); + .replace('', '#') + .replace('', '&') + .replace('', '%') + .replace('', '$'); } /** @@ -31,8 +31,8 @@ export function unescapeChat(estring: string): string { export function safeTags(unsafe: string): string { if (unsafe) { return unsafe - .replace(/>/g, '>') - .replace(/', '>') + .replace('<', '<'); } return ''; } -- cgit From 3cf9a4e0744dbf14dc1dd17d33d9f58478995b2b Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 8 Jan 2023 20:37:36 +0100 Subject: replace all occurences --- webAO/encoding.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'webAO/encoding.ts') diff --git a/webAO/encoding.ts b/webAO/encoding.ts index 2d1f66f..5e53340 100644 --- a/webAO/encoding.ts +++ b/webAO/encoding.ts @@ -4,10 +4,10 @@ */ export function escapeChat(estring: string): string { return estring - .replace('#', '') - .replace('&', '') - .replace('%', '') - .replace('$', ''); + .replaceAll('#', '') + .replaceAll('&', '') + .replaceAll('%', '') + .replaceAll('$', ''); } /** @@ -16,10 +16,10 @@ export function escapeChat(estring: string): string { */ export function unescapeChat(estring: string): string { return estring - .replace('', '#') - .replace('', '&') - .replace('', '%') - .replace('', '$'); + .replaceAll('', '#') + .replaceAll('', '&') + .replaceAll('', '%') + .replaceAll('', '$'); } /** -- cgit From 46ca0989fc39d43ff5ec639351feab08b374d8e0 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sun, 8 Jan 2023 20:38:07 +0100 Subject: i say that and forget 2 --- webAO/encoding.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webAO/encoding.ts') diff --git a/webAO/encoding.ts b/webAO/encoding.ts index 5e53340..3477d7b 100644 --- a/webAO/encoding.ts +++ b/webAO/encoding.ts @@ -31,8 +31,8 @@ export function unescapeChat(estring: string): string { export function safeTags(unsafe: string): string { if (unsafe) { return unsafe - .replace('>', '>') - .replace('<', '<'); + .replaceAll('>', '>') + .replaceAll('<', '<'); } return ''; } -- cgit