@@ -325,29 +325,29 @@ async function changeRoute(
325
325
{ smoothScroll = false , initialLoad = false } = { }
326
326
) : Promise < boolean > {
327
327
const loc = normalizeHref ( location . href )
328
- const { pathname , hash } = new URL ( href , fakeHost )
329
- const currentLoc = new URL ( loc , fakeHost )
328
+ const nextUrl = new URL ( href , location . origin )
329
+ const currentUrl = new URL ( loc , location . origin )
330
330
331
331
if ( href === loc ) {
332
332
if ( ! initialLoad ) {
333
- scrollTo ( hash , smoothScroll )
333
+ scrollTo ( nextUrl . hash , smoothScroll )
334
334
return false
335
335
}
336
336
} else {
337
337
// save scroll position before changing URL
338
338
history . replaceState ( { scrollPosition : window . scrollY } , '' )
339
339
history . pushState ( { } , '' , href )
340
340
341
- if ( pathname === currentLoc . pathname ) {
341
+ if ( nextUrl . pathname === currentUrl . pathname ) {
342
342
// scroll between hash anchors on the same page, avoid duplicate entries
343
- if ( hash !== currentLoc . hash ) {
343
+ if ( nextUrl . hash !== currentUrl . hash ) {
344
344
window . dispatchEvent (
345
345
new HashChangeEvent ( 'hashchange' , {
346
- oldURL : currentLoc . href ,
347
- newURL : href
346
+ oldURL : currentUrl . href ,
347
+ newURL : nextUrl . href
348
348
} )
349
349
)
350
- scrollTo ( hash , smoothScroll )
350
+ scrollTo ( nextUrl . hash , smoothScroll )
351
351
}
352
352
353
353
return false
0 commit comments