Clean all URLs by default in URL state sync
This commit is contained in:
parent
a54c5b7222
commit
d486a89ee7
|
@ -65,6 +65,10 @@ export const syncURLToState = options => {
|
||||||
params = res.params
|
params = res.params
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Clean URL
|
||||||
|
if (url?.endsWith("/index")) {
|
||||||
|
url = url.replace("/index", "")
|
||||||
|
}
|
||||||
log("Navigating to", url, "with params", params)
|
log("Navigating to", url, "with params", params)
|
||||||
cachedGoto(url, params)
|
cachedGoto(url, params)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,8 @@
|
||||||
$: params = routify.params
|
$: params = routify.params
|
||||||
$: routeComponentId = $params.componentId
|
$: 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
|
// Hide new component panel whenever component ID changes
|
||||||
|
const closeNewComponentPanel = url => {
|
||||||
if (url?.endsWith("/new")) {
|
if (url?.endsWith("/new")) {
|
||||||
url = url.replace("/new", "")
|
url = url.replace("/new", "")
|
||||||
}
|
}
|
||||||
|
@ -40,7 +36,7 @@
|
||||||
fallbackUrl: "../",
|
fallbackUrl: "../",
|
||||||
store,
|
store,
|
||||||
routify,
|
routify,
|
||||||
beforeNavigate: cleanUrl,
|
beforeNavigate: closeNewComponentPanel,
|
||||||
})
|
})
|
||||||
|
|
||||||
onDestroy(stopSyncing)
|
onDestroy(stopSyncing)
|
||||||
|
|
Loading…
Reference in New Issue