this repo has no description
1let currentPath = $state(
2 getPathWithoutQuery(window.location.hash.slice(1) || "/"),
3);
4
5function getPathWithoutQuery(hash: string): string {
6 const queryIndex = hash.indexOf("?");
7 return queryIndex === -1 ? hash : hash.slice(0, queryIndex);
8}
9
10window.addEventListener("hashchange", () => {
11 currentPath = getPathWithoutQuery(window.location.hash.slice(1) || "/");
12});
13
14export function navigate(path: string) {
15 currentPath = path;
16 window.location.hash = path;
17}
18
19export function getCurrentPath() {
20 return currentPath;
21}