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