@@ -325,29 +325,29 @@ async function changeRoute(
325325 { smoothScroll = false , initialLoad = false } = { }
326326) : Promise < boolean > {
327327 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 )
330330
331331 if ( href === loc ) {
332332 if ( ! initialLoad ) {
333- scrollTo ( hash , smoothScroll )
333+ scrollTo ( nextUrl . hash , smoothScroll )
334334 return false
335335 }
336336 } else {
337337 // save scroll position before changing URL
338338 history . replaceState ( { scrollPosition : window . scrollY } , '' )
339339 history . pushState ( { } , '' , href )
340340
341- if ( pathname === currentLoc . pathname ) {
341+ if ( nextUrl . pathname === currentUrl . pathname ) {
342342 // scroll between hash anchors on the same page, avoid duplicate entries
343- if ( hash !== currentLoc . hash ) {
343+ if ( nextUrl . hash !== currentUrl . hash ) {
344344 window . dispatchEvent (
345345 new HashChangeEvent ( 'hashchange' , {
346- oldURL : currentLoc . href ,
347- newURL : href
346+ oldURL : currentUrl . href ,
347+ newURL : nextUrl . href
348348 } )
349349 )
350- scrollTo ( hash , smoothScroll )
350+ scrollTo ( nextUrl . hash , smoothScroll )
351351 }
352352
353353 return false
0 commit comments