hashchange: Add hash_util.get_hash_category().

This replaces hashchange.get_main_hash(), which had
a slightly misleading name.  Also, moving this to
hash_util forces us to keep 100% coverage on it.
This commit is contained in:
Steve Howell
2018-12-04 22:48:07 +00:00
committed by Tim Abbott
parent 67fba69b0c
commit 44ef8baff1
3 changed files with 27 additions and 7 deletions

View File

@@ -2,6 +2,11 @@ var hash_util = (function () {
var exports = {};
exports.get_hash_category = function (hash) {
// given "#streams/subscribed", returns "streams"
return hash ? hash.replace(/^#/, "").split(/\//)[0] : "";
};
// Some browsers zealously URI-decode the contents of
// window.location.hash. So we hide our URI-encoding
// by replacing % with . (like MediaWiki).