d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
29 lines
823 B
TypeScript
29 lines
823 B
TypeScript
export function resolveBrowserAppUrl(fallback: string): string {
|
|
if (typeof window === 'undefined') return fallback
|
|
const h = window.location.hostname
|
|
if (h === 'localhost' || h === '127.0.0.1') return fallback.replace(/\/$/, '')
|
|
|
|
try {
|
|
const target = new URL(fallback)
|
|
target.protocol = window.location.protocol
|
|
target.hostname = h
|
|
target.port = ''
|
|
return target.toString().replace(/\/$/, '')
|
|
} catch {
|
|
return fallback
|
|
}
|
|
}
|
|
|
|
export function resolveServerAppUrl(fallback: string, host: string | null, proto?: string | null): string {
|
|
if (!host) return fallback
|
|
|
|
try {
|
|
const target = new URL(fallback)
|
|
target.protocol = `${proto || target.protocol.replace(':', '')}:`
|
|
target.host = host
|
|
return target.toString().replace(/\/$/, '')
|
|
} catch {
|
|
return fallback
|
|
}
|
|
}
|