From ffafbc87d02c6c261087e9f86b673f0ecf4be5a5 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 13 Nov 2023 09:39:20 -0800 Subject: [PATCH] Fix hash and question mark handling in URLs - broke Vue router --- frontend/src/components/BreadCrumb.vue | 6 ++++-- frontend/src/components/FileExplorer.vue | 8 ++------ frontend/src/components/HeaderMain.vue | 6 +++--- frontend/src/repositories/Document.ts | 8 ++++++++ frontend/src/views/ExplorerView.vue | 1 - 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/BreadCrumb.vue b/frontend/src/components/BreadCrumb.vue index ce98fda..7016559 100644 --- a/frontend/src/components/BreadCrumb.vue +++ b/frontend/src/components/BreadCrumb.vue @@ -48,9 +48,11 @@ const navigate = (index: number) => { if (!link) throw Error(`No link at index ${index} (path: ${props.path})`) const url = `/${longest.value.slice(0, index).join('/')}/` const here = `/${longest.value.join('/')}/` + const current = decodeURIComponent(location.hash.slice(1).split('//')[0]) + const u = url.replaceAll('?', '%3F').replaceAll('#', '%23') + if (here.startsWith(current)) router.replace(u) + else router.push(u) link.focus() - if (here.startsWith(location.hash.slice(1))) router.replace(url) - else router.push(url) } const move = (dir: number) => { diff --git a/frontend/src/components/FileExplorer.vue b/frontend/src/components/FileExplorer.vue index 155da5f..f873093 100644 --- a/frontend/src/components/FileExplorer.vue +++ b/frontend/src/components/FileExplorer.vue @@ -50,7 +50,7 @@