17 lines
658 B
TypeScript
17 lines
658 B
TypeScript
export function getTenantCodeFromPath(pathname = window.location.pathname): string {
|
|
const parts = pathname.split('/').filter(Boolean)
|
|
if (parts.length < 2 || parts[0] !== 't') return ''
|
|
return decodeURIComponent(parts[1] || '').toLowerCase()
|
|
}
|
|
|
|
export function getUserRouterBase(pathname = window.location.pathname): string {
|
|
const tenantCode = getTenantCodeFromPath(pathname)
|
|
return `/t/${tenantCode}/`
|
|
}
|
|
|
|
export function getApiBaseURL(pathname = window.location.pathname): string {
|
|
const tenantCode = getTenantCodeFromPath(pathname)
|
|
const origin = import.meta.env.DEV ? 'http://localhost:8080' : ''
|
|
return `${origin}/t/${tenantCode}/v1`
|
|
}
|