File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -137,10 +137,13 @@ export class History {
137
137
}
138
138
onAbort && onAbort ( err )
139
139
}
140
+ const lastRouteIndex = route . matched . length - 1
141
+ const lastCurrentIndex = current . matched . length - 1
140
142
if (
141
143
isSameRoute ( route , current ) &&
142
144
// in the case the route map has been dynamically appended to
143
- route . matched . length === current . matched . length
145
+ lastRouteIndex === lastCurrentIndex &&
146
+ route . matched [ lastRouteIndex ] === current . matched [ lastCurrentIndex ]
144
147
) {
145
148
this . ensureURL ( )
146
149
return abort ( createNavigationDuplicatedError ( current , route ) )
Original file line number Diff line number Diff line change @@ -116,6 +116,23 @@ describe('router.addRoutes', () => {
116
116
expect ( components . length ) . toBe ( 1 )
117
117
expect ( components [ 0 ] . name ) . toBe ( 'A' )
118
118
} )
119
+
120
+ it ( 'allows navigating to the same as current location' , ( ) => {
121
+ const router = new Router ( {
122
+ routes : [
123
+ { path : '/' , component : { } } ,
124
+ { path : '*' , component : { } }
125
+ ]
126
+ } )
127
+
128
+ router . push ( '/not-found' )
129
+
130
+ expect ( router . currentRoute . params ) . toEqual ( { pathMatch : '/not-found' } )
131
+ router . addRoutes ( [ { path : '/not-found' , component : { } } ] )
132
+
133
+ // the navigation should have changed locations
134
+ expect ( router . currentRoute . params ) . toEqual ( { } )
135
+ } )
119
136
} )
120
137
121
138
describe ( 'router.push/replace' , ( ) => {
You can’t perform that action at this time.
0 commit comments