don't write no-ops as new URL history items#4813
Conversation
Security Review ✅
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4813 +/- ##
=====================================
Coverage 90.3% 90.3%
=====================================
Files 444 444
Lines 22577 22577
=====================================
+ Hits 20393 20396 +3
+ Misses 2184 2181 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lmac-1
left a comment
There was a problem hiding this comment.
I added an extra commit to extend this fix to replaceSearchParams for housekeeping. Double checked and this shouldn't have any extra implications. Approved
The no-op guard added in #4813 covered updateSearchParams and replaceSearchParams but not updateHash, and was order-sensitive — a reorder-only param write still stacked a duplicate history entry. Extract a shared pushIfChanged guard (order-insensitive via sorted search params) and a currentURL helper that all three writers seed from, so every history write goes through one correct check.
stuartc
left a comment
There was a problem hiding this comment.
@taylordowns2000 I made a few tweaks here:
Two gaps with the guard/is the url the same. updateHash didn't have it, although it's not actually being called by anything right now which is weird but I'm hesitant to remove it because it's not impossible we will use hash state urls again and if used it'd still push a history entry on a no-op and could bring the stacking bug back. Routed that through a shared function guard too (nothing calls it yet, so just being safe).
The check was order-sensitive - it compared full URL strings, so if replaceSearchParams got the same params in a different order it didn't match and pushed a dupe anyway. Made the comparison ignore param order so a reorder counts as a no-op.
Added a little currentURL helper the three writers seed from - so there's one correct guard instead of two copies and one missing. Ended up being slightly less code overall. Added tests for the new cases too.
Description
This pr closes #4812 by preventing no-ops (where previous URL == new URL) from being added as new URL history items.
Validation steps
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)