From 7127f8831848770229452e7f091c18a229f08d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sat, 11 Nov 2023 23:07:16 +0100 Subject: [PATCH] fix: Keep existing links working MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/router.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/router.js b/src/router.js index 7825ad5c1..998034c01 100644 --- a/src/router.js +++ b/src/router.js @@ -33,7 +33,7 @@ import Overview from './components/overview/Overview.vue' Vue.use(Router) -export default new Router({ +const router = new Router({ mode: 'history', base: generateUrl('/apps/deck/'), linkActiveClass: 'active', @@ -158,3 +158,15 @@ export default new Router({ }, ], }) + +router.beforeEach((to, from, next) => { + // Redirect if fullPath begins with a hash (ignore hashes later in path) + if (to.fullPath.substring(0, 2) === '/#') { + const path = to.fullPath.substring(2) + next(path) + return + } + next() +}) + +export default router