Skip to content

Commit 2f2e3e0

Browse files
committed
fixup! fix(router): drop matrix parameters with null or undefined values
1 parent 1532d46 commit 2f2e3e0

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/router/src/create_url_tree.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ function prefixedWith(segmentGroup: UrlSegmentGroup, startIndex: number, command
500500
if (currentPathIndex > 0 && curr === undefined) break;
501501

502502
if (curr && next && typeof next === 'object' && next.outlets === undefined) {
503-
if (!compare(curr, next, path)) return noMatch;
503+
if (!compare(curr, stringify(next), path)) return noMatch;
504504
currentCommandIndex += 2;
505505
} else {
506506
if (!compare(curr, {}, path)) return noMatch;

‎packages/router/test/create_url_tree.spec.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,15 @@ describe('createUrlTree', () => {
548548
expect(serializer.serialize(relative)).toEqual('/a');
549549
});
550550

551+
it('should match a segment when its matrix parameters are null or undefined', async () => {
552+
const p = serializer.parse('/a/(b//right:c)');
553+
const primary = await createRoot(p, ['/a', {pp: undefined}, 'd']);
554+
expect(serializer.serialize(primary)).toEqual('/a/(d//right:c)');
555+
556+
const secondary = await createRoot(p, ['/a', {pp: null}, {outlets: {right: 'd'}}]);
557+
expect(serializer.serialize(secondary)).toEqual('/a/(b//right:d)');
558+
});
559+
551560
it('should stringify matrix parameters', async () => {
552561
await router.navigateByUrl('/a');
553562
const relative = create(router.routerState.root.children[0], [{pp: 22}]);

0 commit comments

Comments
 (0)