Skip to content

Instantly share code, notes, and snippets.

@hightemp
Forked from danmartens/parse_hash.js
Created June 30, 2020 10:02
Show Gist options
  • Save hightemp/655e8d2b9ac407855285da2a65d79c73 to your computer and use it in GitHub Desktop.
Save hightemp/655e8d2b9ac407855285da2a65d79c73 to your computer and use it in GitHub Desktop.
Parses location.hash into an Object
window.parseHash = function() {
var parsed = {};
var pairs = window.location.hash.replace('#', '').split('&');
pairs.forEach(function(pair) {
parsed[pair.split('=')[0]] = (parseInt(pair.split('=')[1], 10) || pair.split('=')[1]);
});
return parsed;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment