feat: Enhance domain configuration to support hyphen subdomains and update related methods

This commit is contained in:
Alexa
2026-06-25 11:46:34 +03:00
parent a68e9b169f
commit 9c921715c7
4 changed files with 87 additions and 8 deletions
+8 -1
View File
@@ -54,11 +54,18 @@ export function adminApex(): string {
const host = window.location.hostname.toLowerCase();
if (host === 'localhost' || host.endsWith('.localhost')) return 'localhost';
if (host.endsWith('-dev.dork.sh')) return 'dev.dork.sh';
const parts = host.split('.');
return parts.length > 2 ? parts.slice(1).join('.') : host;
}
function serviceHost(subdomain: string, apex: string): string {
return apex === 'dev.dork.sh'
? `${subdomain}-${apex}`
: `${subdomain}.${apex}`;
}
function subdomainUrl(subdomain: string, path: string | null | undefined, query?: string, preserveSlashes = false): string | null {
if (!path) return null;
const apex = adminApex();
@@ -67,7 +74,7 @@ function subdomainUrl(subdomain: string, path: string | null | undefined, query?
const encodedPath = preserveSlashes
? path.split('/').map(encodeURIComponent).join('/')
: encodeURIComponent(path);
return `${scheme}://${subdomain}.${apex}/${encodedPath}${suffix}`;
return `${scheme}://${serviceHost(subdomain, apex)}/${encodedPath}${suffix}`;
}
export interface Room {