From ffc5446a71854fdbb585245f6d7c15f4a81386ab Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 22 Jun 2024 11:14:50 -0700 Subject: strip spaces from usernames --- src/routes/(app)/[username]/(profile)/+layout.svelte | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte index 83c46c27..e3c36417 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.svelte +++ b/src/routes/(app)/[username]/(profile)/+layout.svelte @@ -15,19 +15,20 @@ $: ({ events, user, subject, src, rates, text } = data); $: ({ currency, username: n, display } = subject); - $: username = n.length > 60 ? n.substr(0, 6) : display || n; + $: stripped = n.replace(/\s/g, "") + $: username = n.length > 60 ? n.substr(0, 6) : display || stripped; $: npub = subject.pubkey && bech32m.encode("npub", toWords(hexToUint8Array(subject.pubkey)), 180); - $: lnaddr = `${n}@${$page.url.host}`; - $: profile = `${$page.url.host}/${n}`; + $: lnaddr = `${stripped}@${$page.url.host}`; + $: profile = `${$page.url.host}/${stripped}`; let follow = async () => { user.follows.push([ "p", subject.pubkey, "wss://nostr.coinos.io", - subject.username, + stripped, ]); update(); }; @@ -67,7 +68,7 @@ let reset = async () => { try { - await post(`/${subject.username}/reset`, { password }); + await post(`/${stripped}/reset`, { password }); success("Password reset"); } catch (e) { fail(e.message); -- cgit v1.2.3