diff --git a/src/lib/components/social-link/social-link.svelte b/src/lib/components/social-link/social-link.svelte index c5b5a892f..e0b8abd0c 100644 --- a/src/lib/components/social-link/social-link.svelte +++ b/src/lib/components/social-link/social-link.svelte @@ -30,32 +30,38 @@ }; $: prefix = prefixes[network]; - $: url = `${prefix}${value}`; + + // handle people putting full URLs in their 'com.twitter' ENS records + function parseURL(url: string) { + try { + const validURL = new URL(url); + return validURL.href; + } catch { + // assume they just put their handle + return `${prefix}${value}`; + } + } + + function formatValue(input: string) { + try { + const url = new URL(input); + return url.host + (url.pathname !== '/' ? url.pathname : ''); + } catch { + return input.replaceAll('http://', '').replaceAll('https://', ''); + } + } -