From 5ac5b50e762be98db8de276e609ff14d9381584b Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Wed, 3 Aug 2022 15:51:44 +0530 Subject: [PATCH] fix: use router.go if search string is not same --- src/client/app/router.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 394185595ed8..b81fd5fd23a6 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -132,7 +132,7 @@ export function createRouter( (e) => { const link = (e.target as Element).closest('a') if (link) { - const { href, protocol, hostname, pathname, hash, target } = link + const { href, origin, pathname, hash, search, target } = link const currentUrl = window.location const extMatch = pathname.match(/\.\w+$/) // only intercept inbound links @@ -142,12 +142,15 @@ export function createRouter( !e.altKey && !e.metaKey && target !== `_blank` && - protocol === currentUrl.protocol && - hostname === currentUrl.hostname && + origin === currentUrl.origin && + // don't intercept if non-html extension is present !(extMatch && extMatch[0] !== '.html') ) { e.preventDefault() - if (pathname === currentUrl.pathname) { + if ( + pathname === currentUrl.pathname && + search === currentUrl.search + ) { // scroll between hash anchors in the same page if (hash && hash !== currentUrl.hash) { history.pushState(null, '', hash)