Commit 433768a
committed
fix(react-router): symmetric pathname+search url comparison
The leavingUrl/currentUrl comparison in handleHistoryChange used
`leavingLocationInfo.pathname + leavingLocationInfo.search` on the
left side but `location.pathname` (no search) on the right. For any
route with a non-empty search string, the comparison was always
unequal, so the transition block ran on every history event —
including no-op popstates over same-URL entries (e.g. pushed via
window.history.pushState). That triggered a false POP transition
to the previous route while the browser URL stayed put.
Compares pathname+search on both sides so the block runs only when
the URL actually changed. Verified with a new Cypress regression
that pushes a same-URL state on a search-bearing route, calls
history.back(), and asserts the page does not teleport.1 parent c88c0de commit 433768a
2 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
347 | 366 | | |
348 | 367 | | |
349 | 368 | | |
| |||
0 commit comments