rails/turbolinks — pull request #125 by reednj77 (2012-12-01 02:09:56+00:00)
Title: Preserve anchors - Fix #110

I came up with a few ways to fix the problem (#110), but I think this one is the best because it takes care of two issues.

Unless I'm missing something, the purpose of the `reflectRedirectedUrl` function is to update the newly pushed (from `reflectNewUrl`) history state in the event the ajax request is redirected. However, right now it's doing it whether there was a redirect or not, which most of the time will be unnecessary. The lost anchors are a side effect of this, since it replaces the current state with the `X-XHR-Current-Location` value from the server (which omits anchors). As far as I can tell, my solution preserves the anchors while eliminating unnecessary replaceState calls.