File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,22 @@ describe('Router', () => {
335
335
} )
336
336
} )
337
337
338
+ it ( 'can pass a currentLocation to resolve' , async ( ) => {
339
+ const { router } = await newRouter ( )
340
+ expect ( router . resolve ( { params : { p : 1 } } ) ) . toMatchObject ( {
341
+ path : '/' ,
342
+ } )
343
+ expect (
344
+ router . resolve (
345
+ { params : { p : 1 } } ,
346
+ router . resolve ( { name : 'Param' , params : { p : 2 } } )
347
+ )
348
+ ) . toMatchObject ( {
349
+ name : 'Param' ,
350
+ params : { p : '1' } ,
351
+ } )
352
+ } )
353
+
338
354
it ( 'resolves relative locations' , async ( ) => {
339
355
const { router } = await newRouter ( )
340
356
await router . push ( '/users/posva' )
Original file line number Diff line number Diff line change @@ -221,11 +221,16 @@ export interface Router {
221
221
/**
222
222
* Returns the {@link RouteLocation | normalized version} of a
223
223
* {@link RouteLocationRaw | route location}. Also includes an `href` property
224
- * that includes any existing `base`.
224
+ * that includes any existing `base`. By default the `currentLocation` used is
225
+ * `route.currentRoute` and should only be overriden in advanced use cases.
225
226
*
226
227
* @param to - Raw route location to resolve
228
+ * @param currentLocation - Optional current location to resolve against
227
229
*/
228
- resolve ( to : RouteLocationRaw ) : RouteLocation & { href : string }
230
+ resolve (
231
+ to : RouteLocationRaw ,
232
+ currentLocation ?: RouteLocationNormalizedLoaded
233
+ ) : RouteLocation & { href : string }
229
234
230
235
/**
231
236
* Programmatically navigate to a new URL by pushing an entry in the history
You can’t perform that action at this time.
0 commit comments