my pkgs monorepo
at main 29 lines 721 B view raw
1export function getDomain(url: string): string { 2 try { 3 const urlObj = new URL(url); 4 return urlObj.hostname.replace('www.', ''); 5 } catch { 6 return ''; 7 } 8} 9 10export function atUriToBlueskyUrl(uri: string): string { 11 const parts = uri.split('/'); 12 const did = parts[2]; 13 const rkey = parts[4]; 14 return `https://witchsky.app/profile/${did}/post/${rkey}`; 15} 16 17export function getBlueskyProfileUrl(actor: string): string { 18 return `https://witchsky.app/profile/${actor}`; 19} 20 21export function isExternalUrl(url: string): boolean { 22 if (typeof window === 'undefined') return true; 23 try { 24 const urlObj = new URL(url, window.location.href); 25 return urlObj.origin !== window.location.origin; 26 } catch { 27 return false; 28 } 29}