* 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)
| 541 | * @returns The resolved redirect path as a string. |
| 542 | */ |
| 543 | function 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. |
no test coverage detected