From 93a4914733695b2622573830ce4578e54bdf3090 Mon Sep 17 00:00:00 2001 From: Gabriel Koen Date: Fri, 3 Jan 2014 13:22:16 -0800 Subject: [PATCH] Account for hashbangs Allows hash.js to parse hashbang URLs natively. https://developers.google.com/webmasters/ajax-crawling/docs/specification I didn't include tests because I'm not too familiar with JS unit tests. I didn't include a minified version because I don't know what minification library is used, but I can update the pull request with a minified version if needed. --- hash.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hash.js b/hash.js index 6cb9a4c..536b55e 100644 --- a/hash.js +++ b/hash.js @@ -4,7 +4,7 @@ var hash = (function() { var fromHash = function() { - var params = window.location.hash ? window.location.hash.substr(1).split("&") : [], + var params = window.location.hash ? ( window.location.hash.indexOf("!") === 1 ? window.location.hash.substr(2).split("&") : window.location.hash.substr(1).split("&") ) : [], paramsObject = {}; for(var i = 0; i < params.length; i++) { @@ -53,4 +53,4 @@ var hash = (function() { })(); window.hash = hash; -})(window); \ No newline at end of file +})(window);