MCPcopy Index your code
hub / github.com/angular/angular-cli / resolveRedirectTo

Function resolveRedirectTo

packages/angular/ssr/src/routes/ng-routes.ts:543–554  ·  view source on GitHub ↗

* Resolves the `redirectTo` property for a given route. * * This function processes the `redirectTo` property to ensure that it correctly * resolves relative to the current route path. If `redirectTo` is an absolute path, * it is returned as is. If it is a relative path, it is resolved based on

(routePath: string, redirectTo: string)

Source from the content-addressed store, hash-verified

541 * @returns The resolved redirect path as a string.
542 */
543function resolveRedirectTo(routePath: string, redirectTo: string): string {
544 if (redirectTo[0] === '/') {
545 // If the redirectTo path is absolute, return it as is.
546 return redirectTo;
547 }
548
549 // Resolve relative redirectTo based on the current route path.
550 const segments = routePath.replace(URL_PARAMETER_REGEXP, '*').split('/');
551 segments.pop(); // Remove the last segment to make it relative.
552
553 return joinUrlParts(...segments, redirectTo);
554}
555
556/**
557 * Builds a server configuration route tree from the given server routes configuration.

Callers 2

handleRouteFunction · 0.85
handleSSGRouteFunction · 0.85

Calls 2

joinUrlPartsFunction · 0.90
popMethod · 0.80

Tested by

no test coverage detected