Repository navigation
refactor(@angular/ssr): combine redirect URL parameter helpers and use DefaultUrlSerializer - #34467
alan-agius4 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors URL parameter resolution in Angular SSR by replacing buildPathWithParams and buildQueryWithParams with a unified buildUrlWithParams function that leverages Angular's DefaultUrlSerializer. It also optimizes route parameter replacement and prefix handling. Feedback on the changes points out a potential runtime TypeError when resolving path placeholders if a wildcard or positional placeholder refers to an out-of-bounds index, and suggests adding a fallback to 'undefined'.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors URL and query parameter resolution in the Angular SSR package by consolidating buildPathWithParams and buildQueryWithParams into a single buildUrlWithParams function, and merging replaceRedirectParams into resolveRedirectTo. Feedback on these changes highlights two potential issues: first, appending url.search directly with + for relative redirects could result in malformed URLs with multiple ? characters if the target already contains query parameters; second, resolving path placeholders when fromPath has fewer segments than expected could pass undefined to joinUrlParts, leading to a runtime TypeError.
…e DefaultUrlSerializer Combine `buildPathWithParams` and `buildQueryWithParams` into a single `buildUrlWithParams` helper that uses `DefaultUrlSerializer` from `@angular/router` for query parameter parsing and serialization. Also avoid unnecessary regex/string splitting when redirect targets do not contain parameter placeholders, and only apply `joinUrlParts` to the path portion of redirect URLs so trailing slashes in query parameters or fragments are preserved.
1051c1d to
c663e81
Compare
Follow-up to #34321:
buildPathWithParamsandbuildQueryWithParamsintobuildUrlWithParams.DefaultUrlSerializerfrom@angular/routerfor query parameter parsing and serialization instead of custom regex/encoding helpers.URLSearchParamsinstantiation when redirect targets do not contain placeholders.joinUrlPartsonly to the path portion of redirect targets when prependingbaseHreforX-Forwarded-Prefixso trailing slashes in query parameters or fragments are preserved.