Clean all URLs by default in URL state sync

This commit is contained in:
Andrew Kingston 2023-08-23 10:32:24 +01:00
parent a54c5b7222
commit d486a89ee7
2 changed files with 7 additions and 7 deletions

View File

@ -65,6 +65,10 @@ export const syncURLToState = options => {
params = res.params
}
}
// Clean URL
if (url?.endsWith("/index")) {
url = url.replace("/index", "")
}
log("Navigating to", url, "with params", params)
cachedGoto(url, params)
}

View File

@ -13,12 +13,8 @@
$: params = routify.params
$: routeComponentId = $params.componentId
const cleanUrl = url => {
// Strip trailing slashes
if (url?.endsWith("/index")) {
url = url.replace("/index", "")
}
// Hide new component panel whenever component ID changes
const closeNewComponentPanel = url => {
if (url?.endsWith("/new")) {
url = url.replace("/new", "")
}
@ -40,7 +36,7 @@
fallbackUrl: "../",
store,
routify,
beforeNavigate: cleanUrl,
beforeNavigate: closeNewComponentPanel,
})
onDestroy(stopSyncing)