/** Normalize Vite's public base URL for client-side routing. */ export function normalizeAppBasePath(baseUrl: string): string { const pathname = new URL(baseUrl, "http://buzz.local").pathname; const trimmed = pathname.replace(/\/+$/, ""); return trimmed || "/"; } /** Public path where the web SPA is mounted. */ export function appBasePath(): string { return normalizeAppBasePath(import.meta.env.BASE_URL); } /** Browser href for the SPA root, including its configured base path. */ export function appRootHref(): string { const basePath = appBasePath(); return basePath === "/" ? "/" : `${basePath}/`; }