From 9d06a07df363b0b1a898707cf89a0b4c87ac1345 Mon Sep 17 00:00:00 2001 From: verbiricha Date: Mon, 24 Jul 2023 13:23:39 +0000 Subject: [PATCH] fix: replace all spaces in shortcode (#38) --- src/hooks/emoji.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/emoji.tsx b/src/hooks/emoji.tsx index 362cd80..acfbc3e 100644 --- a/src/hooks/emoji.tsx +++ b/src/hooks/emoji.tsx @@ -25,7 +25,7 @@ export interface EmojiPack { } function cleanShortcode(shortcode?: string) { - return shortcode?.replace(/\s+/, "_"); + return shortcode?.replace(/\s+/g, "_").replace(/_$/, ""); } function toEmojiPack(ev: NostrEvent): EmojiPack { @@ -46,7 +46,7 @@ export function packId(pack: EmojiPack): string { export default function useEmoji(pubkey?: string) { const sub = useMemo(() => { - if(!pubkey) return null; + if (!pubkey) return null; const rb = new RequestBuilder(`emoji:${pubkey}`); rb.withFilter() @@ -72,7 +72,7 @@ export default function useEmoji(pubkey?: string) { }, [userEmoji]); const subRelated = useMemo(() => { - if(!pubkey) return null; + if (!pubkey) return null; const splitted = related.map((t) => t.at(1)!.split(":")); const authors = splitted .map((s) => s.at(1))