Repository navigation
Conversation
Matrix parameters passed to `createUrlTree`, `navigate` or `routerLink`
were stringified unconditionally, so `['/products', {category: undefined}]`
produced `/products;category=undefined` and `paramMap.get('category')`
returned the string `'undefined'`. Query parameters with `null` or
`undefined` values are already removed; matrix parameters now behave
the same way.
atscott
left a comment
There was a problem hiding this comment.
✨ Could we also update prefixedWith to pass stringify(next) to compare (and add a test for it)?
Right now prefixedWith passes the raw next object to compare(curr, next, path), which checks shallowEqual(params, segment.parameters). If the current URL is something like /a/(b//right:c) and a command passes ['/a', {pp: undefined}, 'd'] or ['/a', {pp: undefined}, {outlets: {right: 'd'}}], stringify will drop pp so the segment matches /a, but compare still sees the pp key on next and returns false. That causes updateSegmentGroup to fall back to createNewSegmentGroup and drop the existing child/secondary outlets.
|
Done in 2f2e3e0:
Without the source change the test produces One side effect worth flagging: since the params are stringified before comparing, a command like I pushed it as a fixup commit; happy to squash it if you prefer. |
PR Checklist
PR Type
What is the current behavior?
Matrix parameters with
nullorundefinedvalues are serialized as the literal strings"null"and"undefined":The same values passed as
queryParamsare removed (/products, covered byshould remove query params with null or undefined values). With optional matrix parameters, as the routing guide describes them, an unset value therefore shows up in the URL and reaches the component as a non-empty string.Issue Number: #72208
What is the new behavior?
Matrix parameters with
nullorundefinedvalues are omitted, consistent with query parameters. Setting an existing matrix parameter tonullremoves it from the segment.Does this PR introduce a breaking change?
Other information
The new test fails without the change (
Expected '/a;pp=null;dd=undefined;ee=33' to equal '/a;ee=33') and//packages/router/test:testpasses with it.