Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
579 B ยท 20 lines
TypeScript
123456789101112131415161718192021export const getSubdomain = (name: string, apexName: string) => { if (name === apexName) return null; return name.slice(0, name.length - apexName.length - 1);};
export const getApexDomain = (url: string) => { let domain: string; try { domain = new URL(url).hostname; } catch (_e) { return ""; } const parts = domain.split("."); if (parts.length > 2) { // if it's a subdomain (e.g. dub.vercel.app), return the last 2 parts return parts.slice(-2).join("."); } // if it's a normal domain (e.g. dub.sh), we return the domain return domain;};