Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
HTML 5 History - replaceState using incorrect path when a base tag is set #1159
I found this issue while using the YUI history-html5 module, and I've written up an issue over in the Chromium bug tracker (https://code.google.com/p/chromium/issues/detail?id=279278). The example I put together on the Chromium bug tracker used only native history controls, but I wanted to show an example of how you can run into the same thing when using YUI. I created a Gist (https://gist.github.com/roblund/6430494) containing a simple page. You should be able to reproduce the issue by using the following steps.
YUI is calling replaceState when the page is loaded after clicking back and a 'null' is sent in as the third parameter, which corresponds to URL. You can see this on line 107 of https://github.com/yui/yui3/blob/master/src/history/js/history-html5.js. Chrome/Webkit is then incorrectly then taking the href from the base tag and adding that to the history stack instead of using the current url (which is what Firefox and Internet Explorer do).
The reason this is relevant to YUI is that I believe you could potentially workaround this bug in Chrome/Webkit by changing the 'null' on line 107 of https://github.com/yui/yui3/blob/master/src/history/js/history-html5.js to instead be 'document.URL'. In my limited testing this seems to avoid the Chrome/Webkit issue completely, because you are explicitly setting the url that is sent into replaceState.
If there's anything that doesn't make sense, please let me know and I'll be happy to clarify.