diff --git a/www/common/common-hash.js b/www/common/common-hash.js index 5ba9ec5b3..3aaa7719b 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -117,12 +117,12 @@ Version 1 var hashArr = fixDuplicateSlashes(hash).split('/'); if (['media', 'file', 'user', 'invite'].indexOf(type) === -1) { parsed.type = 'pad'; + parsed.getHash = function () { return hash; }; if (hash.slice(0,1) !== '/' && hash.length >= 56) { // Version 0 // Old hash parsed.channel = hash.slice(0, 32); parsed.key = hash.slice(32, 56); parsed.version = 0; - parsed.getHash = function () { return hash; }; return parsed; } var options; diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index f2e7acc0c..3ba800b49 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -310,7 +310,7 @@ define([ var embed = initValue ? val.embed : Util.isChecked($(link).find('#cp-share-embed')); var present = initValue ? val.present : Util.isChecked($(link).find('#cp-share-present')); - var hash = (edit && hashes.editHash) ? hashes.editHash : hashes.viewHash; + var hash = (!hashes.viewHash || (edit && hashes.editHash)) ? hashes.editHash : hashes.viewHash; var href = origin + pathname + '#' + hash; var parsed = Hash.parsePadUrl(href); return origin + parsed.getUrl({embed: embed, present: present}); diff --git a/www/common/outer/chainpad-netflux-worker.js b/www/common/outer/chainpad-netflux-worker.js index bc1be6e09..be0030ceb 100644 --- a/www/common/outer/chainpad-netflux-worker.js +++ b/www/common/outer/chainpad-netflux-worker.js @@ -68,7 +68,11 @@ define([], function () { // shim between chainpad and netflux var msgIn = function (peerId, msg) { - return msg.replace(/^cp\|([A-Za-z0-9+\/=]+\|)?/, ''); + // NOTE: Hash version 0 contains a 32 characters nonce followed by a pipe + // at the beginning of each message on the server. + // We have to make sure our regex ignores this nonce using {0,20} (our IDs + // should only be 8 characters long) + return msg.replace(/^cp\|([A-Za-z0-9+\/=]{0,20}\|)?/, ''); }; var msgOut = function (msg) {