diff --git a/www/code/main.js b/www/code/main.js index 4c28fe58e..c5e605ef4 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -498,9 +498,7 @@ define([ } // set the hash - if (!readOnly) { - window.location.hash = editHash; - } + if (!readOnly) { Cryptpad.replaceHash(editHash); } Cryptpad.getPadTitle(function (err, title) { if (err) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index d28b1e5e5..1866fb34a 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -225,6 +225,14 @@ define([ return secret; }; + var replaceHash = common.replaceHash = function (hash) { + if (window.history && window.history.replaceState) { + if (!/^#/.test(hash)) { hash = '#' + hash; } + return void window.history.replaceState({}, window.document.title, hash); + } + window.location.hash = hash; + }; + var storageKey = common.storageKey = 'CryptPad_RECENTPADS'; /* diff --git a/www/pad/main.js b/www/pad/main.js index de3e2bcf9..0ad2778b8 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -601,9 +601,7 @@ define([ } // set the hash - if (!readOnly) { - window.location.hash = editHash; - } + if (!readOnly) { Cryptpad.replaceHash(editHash); } Cryptpad.getPadTitle(function (err, title) { if (err) { diff --git a/www/poll/main.js b/www/poll/main.js index ac238e36d..9fbf2cfde 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -914,9 +914,7 @@ define([ editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys); } // set the hash - if (!readOnly) { - window.location.hash = editHash; - } + if (!readOnly) { Cryptpad.replaceHash(editHash); } module.patchText = TextPatcher.create({ realtime: realtime, diff --git a/www/slide/main.js b/www/slide/main.js index 91a174d0f..a291ae02c 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -585,7 +585,7 @@ define([ // set the hash if (!window.location.hash || window.location.hash === '#') { - window.location.hash = editHash; + Cryptpad.replaceHash(editHash); } Cryptpad.getPadTitle(function (err, title) {