sozsoft-platform/ui/src/utils/subdomain.ts

25 lines
576 B
TypeScript
Raw Normal View History

2026-02-24 20:44:16 +00:00
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
}