@@ -612,10 +612,7 @@ export function createNavigationApiRouter(options: RouterApiOptions): Router {
612612 const pathWithSearchAndHash =
613613 destination . pathname + destination . search + destination . hash
614614 const to = resolve ( pathWithSearchAndHash ) as RouteLocationNormalized
615- const from =
616- currentRoute . value === START_LOCATION_NORMALIZED
617- ? lastSuccessfulLocation
618- : currentRoute . value
615+ const from = currentRoute . value
619616
620617 pendingLocation = to
621618
@@ -649,6 +646,14 @@ export function createNavigationApiRouter(options: RouterApiOptions): Router {
649646 }
650647 }
651648
649+ if (
650+ from !== START_LOCATION_NORMALIZED &&
651+ ! ( to as RouteLocationOptions ) . force &&
652+ isSameRouteLocation ( stringifyQuery , from , to )
653+ ) {
654+ return
655+ }
656+
652657 try {
653658 await resolveNavigationGuards ( to , from , navigationInfo )
654659 finalizeNavigation ( to , from )
@@ -811,32 +816,6 @@ export function createNavigationApiRouter(options: RouterApiOptions): Router {
811816 ) {
812817 // see above
813818 started = true
814- const initialLocation = resolve (
815- window . location . pathname +
816- window . location . search +
817- window . location . hash
818- ) as RouteLocationNormalized
819- pendingLocation = initialLocation
820- resolveNavigationGuards ( initialLocation , START_LOCATION_NORMALIZED )
821- . then ( ( ) => {
822- finalizeNavigation ( initialLocation , START_LOCATION_NORMALIZED )
823- } )
824- . catch ( err => {
825- const failure = err as NavigationFailure
826- if (
827- isNavigationFailure ( failure , ErrorTypes . NAVIGATION_GUARD_REDIRECT )
828- ) {
829- return navigate ( ( failure as NavigationRedirectError ) . to , {
830- replace : true ,
831- } )
832- } else {
833- return triggerError (
834- failure ,
835- initialLocation ,
836- START_LOCATION_NORMALIZED
837- )
838- }
839- } )
840819 }
841820
842821 const reactiveRoute = { } as RouteLocationNormalizedLoaded
0 commit comments