Skip to content

Commit 5597165

Browse files
authored
fix: use router.go if search string is not same (#1109)
1 parent 708c361 commit 5597165

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/client/app/router.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function createRouter(
132132
(e) => {
133133
const link = (e.target as Element).closest('a')
134134
if (link) {
135-
const { href, protocol, hostname, pathname, hash, target } = link
135+
const { href, origin, pathname, hash, search, target } = link
136136
const currentUrl = window.location
137137
const extMatch = pathname.match(/\.\w+$/)
138138
// only intercept inbound links
@@ -142,12 +142,15 @@ export function createRouter(
142142
!e.altKey &&
143143
!e.metaKey &&
144144
target !== `_blank` &&
145-
protocol === currentUrl.protocol &&
146-
hostname === currentUrl.hostname &&
145+
origin === currentUrl.origin &&
146+
// don't intercept if non-html extension is present
147147
!(extMatch && extMatch[0] !== '.html')
148148
) {
149149
e.preventDefault()
150-
if (pathname === currentUrl.pathname) {
150+
if (
151+
pathname === currentUrl.pathname &&
152+
search === currentUrl.search
153+
) {
151154
// scroll between hash anchors in the same page
152155
if (hash && hash !== currentUrl.hash) {
153156
history.pushState(null, '', hash)

0 commit comments

Comments
 (0)