This commit is contained in:
k
2026-09-21 23:27:58 +02:00
parent 2974105e25
commit 0810ad4166
3 changed files with 104 additions and 25 deletions
+12
View File
@@ -11,6 +11,18 @@ export function getPath(): string {
return normalizePath(window.location.pathname);
}
/** /chat itself or one conversation page (/chat/<id>). */
export function isChatPath(pathname: string): boolean {
const p = normalizePath(pathname);
return p === "/chat" || p.startsWith("/chat/");
}
/** Conversation id from /chat/<id>, or null on /chat itself. */
export function chatIdFromPath(pathname: string): string | null {
const m = normalizePath(pathname).match(/^\/chat\/([^/]+)$/);
return m ? decodeURIComponent(m[1]!) : null;
}
/** Client-side navigation without reload (same-origin path only). */
export function navigate(to: string, replace = false): void {
const dest = normalizePath(to);