)
})
+ it('drops non existent params', () => {
+ assertRecordMatch(
+ { path: '/', name: 'home', components },
+ { name: 'home', params: { a: 'b' } },
+ { name: 'home', path: '/', params: {} }
+ )
+ assertRecordMatch(
+ { path: '/:b', name: 'a', components },
+ { name: 'a', params: { a: 'a', b: 'b' } },
+ { name: 'a', path: '/b', params: { b: 'b' } }
+ )
+ })
+
it('drops optional params', () => {
assertRecordMatch(
{ path: '/:a/:b?', name: 'p', components },
// TODO: only keep optional params coming from a parent record
matcher.keys.filter(k => !k.optional).map(k => k.name)
),
- location.params
+ // discard any existing params in the current location that do not exist here
+ // #1497 this ensures better active/exact matching
+ location.params &&
+ paramsFromLocation(
+ location.params,
+ matcher.keys.map(k => k.name)
+ )
)
// throws if cannot be stringified
path = matcher.stringify(params)
// matcher should have a value after the loop
if (matcher) {
- // TODO: dev warning of unused params if provided
// we know the matcher works because we tested the regexp
params = matcher.parse(path)!
name = matcher.record.name