await router.push({ name: 'optional', params: {} })
})
+ it('handles undefined path', async () => {
+ const { router } = await newRouter()
+
+ const route1 = router.resolve({
+ path: undefined,
+ params: { p: 'a' },
+ })
+ expect(route1.path).toBe('/')
+ expect(route1.params).toEqual({ p: 'a' })
+ })
+
it('removes null/undefined optional params when current location has it', async () => {
const { router } = await newRouter()
)
// throws if cannot be stringified
path = matcher.stringify(params)
- } else if ('path' in location) {
+ } else if ('path' in location && location.path != null) {
// no need to resolve the path with the matcher as it was provided
// this also allows the user to control the encoding
path = location.path
let matcherLocation: MatcherLocationRaw
// path could be relative in object as well
- if ('path' in rawLocation) {
+ if ('path' in rawLocation && rawLocation.path != null) {
if (
__DEV__ &&
'params' in rawLocation &&