fix(@angular/ssr): use router to normalize URLs for comparison#33057
Merged
alan-agius4 merged 2 commits intoangular:mainfrom Apr 28, 2026
Merged
fix(@angular/ssr): use router to normalize URLs for comparison#33057alan-agius4 merged 2 commits intoangular:mainfrom
alan-agius4 merged 2 commits intoangular:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the URL construction logic in the Angular SSR utility to use the Router for parsing and serialization, ensuring consistency with the router's configuration. It also expands the test suite to cover complex and encoded URL scenarios. The feedback suggests renaming the constructDecodedUrl function to constructNormalizedUrl to accurately reflect its updated behavior of returning a serialized URL rather than a decoded one.
Updates `constructDecodedUrl` in the SSR engine to use the Angular `Router` for parsing and serializing URLs instead of manual string manipulation and decoding. This ensures that the URL comparison used to determine if a redirect is necessary is consistent with how the router interprets and serializes the URL. This prevents issues where differences in encoding or edge cases (like duplicate query parameters or empty values) could lead to incorrect comparison results and unexpected redirects. Also updates tests to include edge cases for query parameters and paths to verify this behavior. Fixes angular#33053
…oute tree Updates the `getPathSegments` method in `RouteTree` to decode each path segment using `decodeURIComponent` after splitting the route by `/`. This ensures that encoded characters in URL segments (such as spaces or encoded slashes) are correctly interpreted when matching incoming requests against the route tree. This prevents issues where encoded segments would fail to match their corresponding route definitions or wildcard patterns in the tree. Also reverts experimental changes in `url.ts` and `router.ts` regarding matrix parameter handling, as the simple change in `route-tree.ts` is sufficient to resolve the issue and passes all tests. Adds a test in `router_spec.ts` to verify that a URL with an encoded parameter containing spaces and slashes (`Bob%20%2F%20Roberts`) correctly matches a wildcard route (`/user/*`). Fixes angular#33044
hawkgs
approved these changes
Apr 27, 2026
dgp1130
approved these changes
Apr 27, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates
constructDecodedUrlin the SSR engine to use the AngularRouterfor parsing and serializing URLs instead of manual string manipulation and decoding.This ensures that the URL comparison used to determine if a redirect is necessary is consistent with how the router interprets and serializes the URL. This prevents issues where differences in encoding or edge cases (like duplicate query parameters or empty values) could lead to incorrect comparison results and unexpected redirects.
Also updates tests to include edge cases for query parameters and paths to verify this behavior.
Fixes #33053