Fix various issues

pull/1/head
yflory 4 years ago
parent e4b616f1fc
commit cb8bf2cdeb

@ -47,8 +47,8 @@ define([
var href = '/'+ x[0] +'/'; var href = '/'+ x[0] +'/';
var attr = isEnabled ? { href: href } : { var attr = isEnabled ? { href: href } : {
onclick: function () { onclick: function () {
var href = Hash.hashToHref('', 'login'); var loginURL = Hash.hashToHref('', 'login');
var url = Hash.getNewPadURL(href, { href: href }); var url = Hash.getNewPadURL(loginURL, { href: href });
window.location.href = url; window.location.href = url;
} }
}; };

@ -236,7 +236,7 @@ Version 4: Data URL when not a realtime link yet (new pad or "static" app)
parsed.ownerKey = getOwnerKey(options); parsed.ownerKey = getOwnerKey(options);
}; };
// Version 4: only login or newpad options, smae for all the apps // Version 4: only login or newpad options, same for all the apps
if (hashArr[1] && hashArr[1] === '4') { if (hashArr[1] && hashArr[1] === '4') {
parsed.getHash = function (opts) { parsed.getHash = function (opts) {
if (!opts || !Object.keys(opts).length) { return ''; } if (!opts || !Object.keys(opts).length) { return ''; }
@ -653,9 +653,6 @@ Version 4: Data URL when not a realtime link yet (new pad or "static" app)
// Valid hash? // Valid hash?
if (parsed.hash) { if (parsed.hash) {
if (!parsed.hashData) { return; } if (!parsed.hashData) { return; }
// New pad: only newPadOpts allowed
if (Object.keys(parsed.hashData).length === 1 &&
parsed.hashData.newPadOpts) { return true; }
// Version should be a number // Version should be a number
if (typeof(parsed.hashData.version) === "undefined") { return; } if (typeof(parsed.hashData.version) === "undefined") { return; }
// pads and files should have a base64 (or hex) key // pads and files should have a base64 (or hex) key
@ -670,7 +667,7 @@ Version 4: Data URL when not a realtime link yet (new pad or "static" app)
Hash.decodeDataOptions = function (opts) { Hash.decodeDataOptions = function (opts) {
var b64 = decodeURIComponent(opts); var b64 = decodeURIComponent(opts);
var str = Nacl.util.encodeUTF8(Nacl.util.decodeBase64(b64)); var str = Nacl.util.encodeUTF8(Nacl.util.decodeBase64(b64));
return JSON.parse(str); return Util.tryParse(str) || {};
}; };
Hash.encodeDataOptions = function (opts) { Hash.encodeDataOptions = function (opts) {
var str = JSON.stringify(opts); var str = JSON.stringify(opts);

@ -94,6 +94,7 @@ define([
localStorage.removeItem(k); localStorage.removeItem(k);
delete localStorage[k]; delete localStorage[k];
}); });
sessionStorage.clear();
try { try {
Object.keys(localStorage || {}).forEach(function (k) { Object.keys(localStorage || {}).forEach(function (k) {
// Remvoe everything in localStorage except CACHE and FS_hash // Remvoe everything in localStorage except CACHE and FS_hash

Loading…
Cancel
Save