rails/turbolinks — pull request #430 by phallguy (2014-11-09 04:32:06+00:00)
Title: Fix back button broken on redirect

Fixes regression introduced by 52284ea

Start Page 1
Click Link to Page 2
Server redirects to Page 3
Click Link to Page 4
Hit Back Button, Page 3 is Sown
Hit Back Button, Page 3 is Shown again, should be page 1

Without the fix, page 3 is shown again, though the URL does reflect Page 1.

The problem seems to relate to reflectRedirectUrl which uses currentState instead of window.history.state. currentState is set by changePage so calling reflectRedirectedUrl before changePage uses the wrong state.

Changing reflectRedirectedUrl to use window.history.state instead seems to resolve the issue.