sozsoft-platform/ui/src/utils/subdomain.ts
Sedat Öztürk 429227df1d Initial
2026-02-24 23:44:16 +03:00

24 lines
576 B
TypeScript

export const defaultDomain = 'Sozsoft'
export const getSubdomain = (): string | null => {
if (typeof window === 'undefined') return null
const hostname = window.location.hostname
const parts = hostname.split('.')
// localhost veya normal domain ise subdomain yok
if (hostname === 'localhost' || parts.length < 3) {
return null
}
// Default subdomain ise null döndür
if (parts[0].toUpperCase() === defaultDomain) {
return null
}
return parts[0].toUpperCase()
}
export const hasSubdomain = (): boolean => {
return getSubdomain() !== null
}