Fix an issue with hashes ending with a slash
This commit is contained in:
parent
d9b5eb8a97
commit
a51a35da70
@ -270,5 +270,10 @@ Version 2
|
|||||||
return '/blob/' + id.slice(0,2) + '/' + id;
|
return '/blob/' + id.slice(0,2) + '/' + id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var serializeHash = Hash.serializeHash = function (hash) {
|
||||||
|
if (hash && hash.slice(-1) !== "/") { hash += "/"; }
|
||||||
|
return hash;
|
||||||
|
};
|
||||||
|
|
||||||
return Hash;
|
return Hash;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -82,6 +82,7 @@ define([
|
|||||||
common.createChannelId = Hash.createChannelId;
|
common.createChannelId = Hash.createChannelId;
|
||||||
common.findWeaker = Hash.findWeaker;
|
common.findWeaker = Hash.findWeaker;
|
||||||
common.findStronger = Hash.findStronger;
|
common.findStronger = Hash.findStronger;
|
||||||
|
common.serializeHash = Hash.serializeHash;
|
||||||
|
|
||||||
// History
|
// History
|
||||||
common.getHistory = function (config) { return History.create(common, config); };
|
common.getHistory = function (config) { return History.create(common, config); };
|
||||||
@ -166,6 +167,7 @@ define([
|
|||||||
var login = common.login = function (hash, name, cb) {
|
var login = common.login = function (hash, name, cb) {
|
||||||
if (!hash) { throw new Error('expected a user hash'); }
|
if (!hash) { throw new Error('expected a user hash'); }
|
||||||
if (!name) { throw new Error('expected a user name'); }
|
if (!name) { throw new Error('expected a user name'); }
|
||||||
|
hash = common.serializeHash(hash);
|
||||||
localStorage.setItem(userHashKey, hash);
|
localStorage.setItem(userHashKey, hash);
|
||||||
localStorage.setItem(userNameKey, name);
|
localStorage.setItem(userNameKey, name);
|
||||||
if (cb) { cb(); }
|
if (cb) { cb(); }
|
||||||
@ -216,11 +218,12 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var getUserHash = common.getUserHash = function () {
|
var getUserHash = common.getUserHash = function () {
|
||||||
var hash;
|
var hash = localStorage[userHashKey];
|
||||||
[sessionStorage, localStorage].some(function (s) {
|
|
||||||
var h = s[userHashKey];
|
if (hash) {
|
||||||
if (h) { return (hash = h); }
|
var sHash = common.serializeHash(hash);
|
||||||
});
|
if (sHash !== hash) { localStorage[userHashKey] = sHash; }
|
||||||
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user