Write on the margins of the internet. Powered by the AT Protocol. margin.at
extension web atproto comments
at ui-refactor 23 lines 594 B view raw
1export function getLinkIconType(url) { 2 if (!url) return "link"; 3 try { 4 const hostname = new URL(url).hostname; 5 if (hostname.includes("github.com")) return "github"; 6 if (hostname.includes("bsky.app")) return "bluesky"; 7 if (hostname.includes("linkedin.com")) return "linkedin"; 8 if (hostname.includes("tangled.org")) return "tangled"; 9 if (hostname.includes("youtube.com")) return "youtube"; 10 } catch { 11 /* ignore */ 12 } 13 return "link"; 14} 15 16export function formatUrl(url) { 17 try { 18 return new URL(url).hostname; 19 } catch { 20 /* ignore */ 21 return url; 22 } 23}