Repository navigation
fix(@angular/ssr): decode pathname when constructing server asset path - #33970
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the SSR application to support non-ASCII routes and base hrefs by decoding URI components using decodeURIComponent with fallback handling. It also introduces comprehensive test coverage for non-ASCII paths. The review feedback suggests extracting a safeDecode helper to reduce code duplication and preserve variable immutability, as well as adding an afterEach hook in the tests to restore the manifest state and ensure proper test isolation.
Ensure that the request pathname is decoded using `decodeURIComponent` when resolving server asset paths in `AngularServerApp`. Previously, `buildServerAssetPathFromRequest` used the raw percent-encoded `pathname` from `new URL(request.url)` while prerendered assets were registered in the manifest under decoded names. Consequently, prerendered routes with non-ASCII or percent-encoded characters failed asset lookup and fell through to server-side rendering or 404. Closes angular#33966
c0f5ed4 to
9582885
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
AngularAppEngine/AngularServerAppresolves prerendered static assets using the raw percent-encoded pathname fromnew URL(request.url)without decoding. However, during the build, prerendered assets are registered in the manifest under their decoded names (e.g./مقالات/دليل/index.html). For any prerendered route containing non-ASCII characters or percent-encoded characters, asset lookup fails and requests fall back to server-side rendering or 404.Issue Number: Closes #33966
What is the new behavior?
The request pathname is decoded using
decodeURIComponentinbuildServerAssetPathFromRequestbefore looking up the asset inmanifest.assets, ensuring requests for prerendered non-ASCII routes correctly match and serve their prerendered files.Does this PR introduce a breaking change?
Other information