Title: fix(@angular/ssr): resolve the request path through the router's URL grammar before matching by glivter · Pull Request #34091 · angular/angular-cli · GitHub
Open Graph Title: fix(@angular/ssr): resolve the request path through the router's URL grammar before matching by glivter · Pull Request #34091 · angular/angular-cli
X Title: fix(@angular/ssr): resolve the request path through the router's URL grammar before matching by glivter · Pull Request #34091 · angular/angular-cli
Description: PR Checklist The commit message follows our guidelines Tests for the changes have been added (for bug fixes / features) Docs have been added / updated (for bug fixes / features) PR Type Bugfix What is the current behavior? Issue Number: #33555 ServerRouter.match tokenises the pathname by splitting on /, while @angular/router parses it with DefaultUrlSerializer, a grammar in which (, ), ; and // are metacharacters and unparseable input is silently discarded. The two disagree on which route a request is. Verified against the published @angular/router 22.1.6, serialize(parse(x)): input router resolves to /page) /page /page( /page /page; /page /(page) /page /a/1//b /a/1 Because ServerRouter.match selects the response's headers, status, renderMode and preload while @angular/router selects the component that renders into the body, appending one character to a path produces a response whose body comes from one route and whose per-route configuration comes from another. A route configured with Cache-Control: no-store, private and X-Frame-Options: DENY is served under the catch-all's policy with neither header, and a route declared RenderMode.Client is server-rendered. The @angular/router side is intentional. (name:seg) is the documented secondary-outlet syntax, ;k=v the documented matrix-parameter syntax, and angular/angular#64507 deliberately made an unnamed (...) group mean the primary outlet. What is the new behavior? ServerRouter.match resolves the pathname through the router's own serializer before tokenising it, so both matchers agree on which route a request is. This is the same divergence that 85c18b4 fixed for matrix parameters, where it surfaced as URLs failing to match their route. stripMatrixParams handled that case; parentheses and interior // are the remaining ones. Going through the serializer covers the class rather than the next symptom, and @angular/router is already a peer dependency of this package. Normalisation runs before stripMatrixParams, because the serializer preserves matrix parameters, so they are still stripped exactly as today. A path the serializer cannot parse is returned unchanged, so malformed percent-encoding keeps its existing behaviour. Known residual, stated up front: an application that supplies a custom UrlSerializer still diverges, because this normalises with DefaultUrlSerializer. The durable fix is to build and query the route tree through the serializer the application injects, which is a larger change. I am happy to take this in that direction instead, or to have this closed in favour of an internal patch if one is already in progress; the issue matters more than the PR. Tests packages/angular/ssr/test/utils/url_spec.ts covers normalizeUrlPath directly: the divergent spellings, an unchanged ordinary path, preserved encoding including /, preserved matrix parameters, and an unparseable path returned as-is. Every expected value was measured against @angular/router 22.1.6 rather than assumed. packages/angular/ssr/test/routes/router_spec.ts covers the end-to-end selection: /home), /home(, /home; and /(home) select the same route metadata as /home, /user/123//x selects /user/*, and an unknown route still matches nothing. Both were confirmed to FAIL against main before the change, with the failure reproducing the real defect: /home): Expected undefined to equal Object({ route: '/home', renderMode: 0 }). //packages/angular/ssr/test:test is green with the change, 257 specs. Does this PR introduce a breaking change? Yes No Every path that does not use the router's metacharacters tokenises exactly as before. The behaviour change is limited to paths where the two matchers currently disagree, and there the server now agrees with what is actually rendered. Other information Originally filed as #34090, which turned out to be a duplicate of #33555 and has been closed in its favour; the additional coverage from it is now a comment on #33555. My prior-art sweep missed #33555 because I searched my own vocabulary, "route-tree tokenisation" and "matcher divergence", rather than the words a reporter would use. Credit to @SkyZeroZx for catching it. Also reported via the Google OSS VRP as 559764571, which the Bug Hunter Team triaged and invited me to disclose publicly. This change and its testing were produced with AI assistance. The equivalence table and every value asserted in the new tests were executed against the published @angular/router 22.1.6 rather than reasoned about, and the tests were confirmed to fail before the fix.
Open Graph Description: PR Checklist The commit message follows our guidelines Tests for the changes have been added (for bug fixes / features) Docs have been added / updated (for bug fixes / features) PR Type Bugf...
X Description: PR Checklist The commit message follows our guidelines Tests for the changes have been added (for bug fixes / features) Docs have been added / updated (for bug fixes / features) PR Type Bugf...
Opengraph URL: https://github.com/angular/angular-cli/pull/34091
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:2f822b32-5c01-4ccb-fab9-6eebf83f932a |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E092:378BB1:E6A6A:13DEDD:6AFDD800 |
| html-safe-nonce | 7aad7ed91b462cf4e1544c34534abcd418c4b3865b880079a257a46d85c1a2ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDkyOjM3OEJCMTpFNkE2QToxM0RFREQ6NkFGREQ4MDAiLCJ2aXNpdG9yX2lkIjoiNzMzODI4MjQzODI3NzA2MDYwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b20ba1b5d1f8e7daa62c5b31a3e2e9c2dae2fc317bb4897b28f06479ef40b807 |
| hovercard-subject-tag | pull_request:4530702606 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/angular/angular-cli/pull/34091/files |
| twitter:image | https://avatars.githubusercontent.com/u/8862088?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/8862088?s=400&v=4 |
| og:image:alt | PR Checklist The commit message follows our guidelines Tests for the changes have been added (for bug fixes / features) Docs have been added / updated (for bug fixes / features) PR Type Bugf... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9918bd4004419458bcd838065ac2a76b76ebd11705d73909fff5ab99e996fa23 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a231c174493a6a442c0b0544475c918b30128208 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width