})
})
+ it('can pass a currentLocation to resolve', async () => {
+ const { router } = await newRouter()
+ expect(router.resolve({ params: { p: 1 } })).toMatchObject({
+ path: '/',
+ })
+ expect(
+ router.resolve(
+ { params: { p: 1 } },
+ router.resolve({ name: 'Param', params: { p: 2 } })
+ )
+ ).toMatchObject({
+ name: 'Param',
+ params: { p: '1' },
+ })
+ })
+
it('resolves relative locations', async () => {
const { router } = await newRouter()
await router.push('/users/posva')
/**
* Returns the {@link RouteLocation | normalized version} of a
* {@link RouteLocationRaw | route location}. Also includes an `href` property
- * that includes any existing `base`.
+ * that includes any existing `base`. By default the `currentLocation` used is
+ * `route.currentRoute` and should only be overriden in advanced use cases.
*
* @param to - Raw route location to resolve
+ * @param currentLocation - Optional current location to resolve against
*/
- resolve(to: RouteLocationRaw): RouteLocation & { href: string }
+ resolve(
+ to: RouteLocationRaw,
+ currentLocation?: RouteLocationNormalizedLoaded
+ ): RouteLocation & { href: string }
/**
* Programmatically navigate to a new URL by pushing an entry in the history