fix: replace all spaces in shortcode (#38)

This commit is contained in:
2023-07-24 13:23:39 +00:00
parent 26b8890245
commit 9d06a07df3

View File

@ -25,7 +25,7 @@ export interface EmojiPack {
} }
function cleanShortcode(shortcode?: string) { function cleanShortcode(shortcode?: string) {
return shortcode?.replace(/\s+/, "_"); return shortcode?.replace(/\s+/g, "_").replace(/_$/, "");
} }
function toEmojiPack(ev: NostrEvent): EmojiPack { function toEmojiPack(ev: NostrEvent): EmojiPack {
@ -46,7 +46,7 @@ export function packId(pack: EmojiPack): string {
export default function useEmoji(pubkey?: string) { export default function useEmoji(pubkey?: string) {
const sub = useMemo(() => { const sub = useMemo(() => {
if(!pubkey) return null; if (!pubkey) return null;
const rb = new RequestBuilder(`emoji:${pubkey}`); const rb = new RequestBuilder(`emoji:${pubkey}`);
rb.withFilter() rb.withFilter()
@ -72,7 +72,7 @@ export default function useEmoji(pubkey?: string) {
}, [userEmoji]); }, [userEmoji]);
const subRelated = useMemo(() => { const subRelated = useMemo(() => {
if(!pubkey) return null; if (!pubkey) return null;
const splitted = related.map((t) => t.at(1)!.split(":")); const splitted = related.map((t) => t.at(1)!.split(":"));
const authors = splitted const authors = splitted
.map((s) => s.at(1)) .map((s) => s.at(1))