frontend client for gemstone. decentralised workplace app
at main 443 B view raw
1/** 2 * Checks if a string is a domain 3 * does NOT do TLD-level checks. Any domain/NSID-like string will pass this check 4 */ 5export const isDomain = (str: string) => { 6 try { 7 const url = new URL(str.includes("://") ? str : `https://${str}`); 8 return ( 9 (url.hostname.includes(".") && !url.hostname.startsWith(".")) || 10 url.hostname === "localhost" 11 ); 12 } catch { 13 return false; 14 } 15};