fix(@angular/build): ensure correct URL joining for prerender routes#31884
Merged
alan-agius4 merged 1 commit intoangular:mainfrom Nov 20, 2025
Merged
fix(@angular/build): ensure correct URL joining for prerender routes#31884alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4 merged 1 commit intoangular:mainfrom
Conversation
1fa347a to
432886b
Compare
This commit addresses an issue where prerendering with i18n and a `routesFile` could lead to infinite redirect loops or failure to prerender `index.html`. The previous `urlJoin` utility was replaced with more robust URL manipulation functions (`joinUrlParts`, `addTrailingSlash`, `stripLeadingSlash`) to ensure that paths are correctly constructed, especially when dealing with base hrefs and locale subpaths. This ensures that routes from the `routesFile` are correctly joined with the base href, preventing malformed URLs that cause the redirection issues. Closes angular#31877
432886b to
88b906d
Compare
hybrist
approved these changes
Nov 20, 2025
Contributor
hybrist
left a comment
There was a problem hiding this comment.
Is this code subtle enough that it warrants a few test cases?
| if (part[0] === '/') { | ||
| normalizedPart = normalizedPart.slice(1); | ||
| } | ||
| if (part[part.length - 1] === '/') { |
Contributor
There was a problem hiding this comment.
Do we get to use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at here since it's been widely available since March 2022?
Collaborator
Author
There was a problem hiding this comment.
This is copied from the SSR package. I will do a followup to change the .at(-1).
Collaborator
Author
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This commit addresses an issue where prerendering with i18n and a
routesFilecould lead to infinite redirect loops or failure to prerenderindex.html.The previous
urlJoinutility was replaced with more robust URL manipulation functions (joinUrlParts,addTrailingSlash,stripLeadingSlash) to ensure that paths are correctly constructed, especially when dealing with base hrefs and locale subpaths. This ensures that routes from theroutesFileare correctly joined with the base href, preventing malformed URLs that cause the redirection issues.Closes #31877