Fix Fetch dropping repeated form fields and leaking src into history (2.x) - #644
Fix Fetch dropping repeated form fields and leaking src into history (2.x)#644titouanmathis wants to merge 1 commit into
Conversation
Two faults in the same resolver, both reported from a facet filter form. Folding a GET form onto the base URL used `set` per field, which keeps one value per name. A checkbox group is repeated names by design, so ticking a second box changed nothing: FormData held both values, `new URLSearchParams(FormData)` serialised both, and the request carried one. The fold now deletes the base's values the first time it meets a name and appends after that, which keeps the override `set` was there for and stops discarding the rest. History pushed the URL that was fetched, so a `src` pointing at a lighter endpoint put its own parameters in the address bar and in anything a visitor copied out of it. History now follows the element's own destination — a link's href, a form's action folded with its data — through a new `historyUrl` getter. A URL passed explicitly to `fetch()` is still pushed as given. Nothing changes for an element without `src`, where the two URLs are the same.
Code ReviewRisk: Medium — issues that should be addressed before merge. This change preserves repeated GET form values and separates the requested URL from the URL written to browser history. It adds URL-resolution coverage and documentation for both behaviors, but the new history state persists across updates and can override URLs supplied to later direct 1 issue found:
Review usage: 19,961 in (3,677 cached) / 696 out tokens — $0.0124 (openrouter/openai/gpt-5.6-luna, thinking: low) Reviewed by @weareikko/code-review v0.9.5 for commit a8e95f7. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #644 +/- ##
============================================
+ Coverage 87.80% 87.85% +0.05%
Complexity 145 145
============================================
Files 153 153
Lines 5443 5460 +17
Branches 1037 1040 +3
============================================
+ Hits 4779 4797 +18
+ Misses 580 579 -1
Partials 84 84
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Cherry-pick of 7edbbdd from #643, which landed on
main.Fetch.tswas byte-identical on the two branches, so it applied without conflict.See #643 for the reasoning. In short:
setper entry — a checkbox group could never send more than one term;srcpointing at a lighter endpoint leaked its parameters into the address bar. The newhistoryUrlgetter follows the element's own destination instead.Nothing changes for an element without
src.Verified on this branch: 100 Fetch tests, full suite green.