Skip to content

Commit

Permalink
fix: use router.go if search string is not same (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Aug 3, 2022
1 parent 708c361 commit 5597165
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/client/app/router.ts
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 5597165

Please sign in to comment.