diff --git a/static/js/browser_history.js b/static/js/browser_history.js index 654c80825a..db67011267 100644 --- a/static/js/browser_history.js +++ b/static/js/browser_history.js @@ -30,6 +30,15 @@ export function set_hash_before_overlay(hash) { state.hash_before_overlay = hash; } +export function update_web_public_hash(hash) { + // Returns true if hash is web public compatible. + if (hash_util.is_spectator_compatible(hash)) { + state.spectator_old_hash = hash; + return true; + } + return false; +} + export function save_old_hash() { state.old_hash = window.location.hash; diff --git a/static/js/hashchange.js b/static/js/hashchange.js index 0d3c41e03b..35567adafd 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -315,14 +315,9 @@ function do_hashchange_overlay(old_hash) { function hashchanged(from_reload, e) { const current_hash = window.location.hash; const old_hash = e && (e.oldURL ? new URL(e.oldURL).hash : browser_history.old_hash()); + const is_hash_web_public_compatible = browser_history.update_web_public_hash(current_hash); const was_internal_change = browser_history.save_old_hash(); - - const is_hash_web_public_compatible = hash_util.is_spectator_compatible(current_hash); - if (is_hash_web_public_compatible) { - browser_history.state.spectator_old_hash = current_hash; - } - if (was_internal_change) { return undefined; }