Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/angular/ssr/src/routes/ng-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ function resolveRedirectTo(routePath: string, redirectTo: string): string {
}

// Resolve relative redirectTo based on the current route path.
const segments = routePath.replace(URL_PARAMETER_REGEXP, '*').split('/');
const segments = routePath.replace(URL_PARAMETER_GLOBAL_REGEXP, '*').split('/');
segments.pop(); // Remove the last segment to make it relative.

return joinUrlParts(...segments, redirectTo);
Expand Down
29 changes: 29 additions & 0 deletions packages/angular/ssr/test/routes/ng-routes_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,35 @@ describe('extractRoutesAndCreateRouteTree', () => {
]);
});

it('should extract nested redirects with multiple path parameters', async () => {
setAngularAppTestingManifest(
[
{
path: ':param1/:param2',
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'thing',
},
{
path: 'thing',
component: DummyComponent,
},
],
},
],
[{ path: '**', renderMode: RenderMode.Server }],
);

const { routeTree, errors } = await extractRoutesAndCreateRouteTree({ url });
expect(errors).toHaveSize(0);
expect(routeTree.toObject()).toEqual([
{ route: '/*/*', renderMode: RenderMode.Server, redirectTo: '/*/*/thing' },
{ route: '/*/*/thing', renderMode: RenderMode.Server },
]);
});

it('should not resolve parameterized routes for SSG when `invokeGetPrerenderParams` is false', async () => {
setAngularAppTestingManifest(
[
Expand Down
Loading