From 77679dbf69ae097cefbbcabe9c2b952d446e9677 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 15 Feb 2022 22:11:07 +0000 Subject: add username in profile --- src/lib/utils.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/lib/utils.ts') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 5d8ecc8..f93f68e 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -120,4 +120,16 @@ export function shuffle(a: T[]): T[] { ;[a[i], a[j]] = [a[j], a[i]] } return a +} + +const emojiRegex = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g + + +export function twemojiHtml(s: string) { + const htmlEncoded = s.replace('<', '<').replace('>', '>').replace('&', '&') + // replace unicode emojis with + const asTwemoji = htmlEncoded.replace(emojiRegex, (match) => { + return `` + }) + return asTwemoji } \ No newline at end of file -- cgit