reencode url to remove ver
This commit is contained in:
parent
2d2071b0fb
commit
ec9ffbd6ba
1 changed files with 14 additions and 0 deletions
14
js/kiri.js
14
js/kiri.js
|
|
@ -65,6 +65,9 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
if (SETUP.rm) renderMode = parseInt(SETUP.rm[0]);
|
if (SETUP.rm) renderMode = parseInt(SETUP.rm[0]);
|
||||||
DBUG.enable();
|
DBUG.enable();
|
||||||
|
|
||||||
|
// remove version, preserve other settings
|
||||||
|
WIN.history.replaceState({},'','/kiri/' + encodeOpt(SETUP) + LOC.hash);
|
||||||
|
|
||||||
// add show() to catalog for API
|
// add show() to catalog for API
|
||||||
CATALOG.show = showCatalog;
|
CATALOG.show = showCatalog;
|
||||||
|
|
||||||
|
|
@ -404,6 +407,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
let opt = {}, kv, kva;
|
let opt = {}, kv, kva;
|
||||||
// handle kiri legacy and proper url encoding better
|
// handle kiri legacy and proper url encoding better
|
||||||
ov.replace(/&/g,',').split(',').forEach(function(el) {
|
ov.replace(/&/g,',').split(',').forEach(function(el) {
|
||||||
|
el = el.replace(/=/g,':');
|
||||||
kv = decodeURIComponent(el).split(':');
|
kv = decodeURIComponent(el).split(':');
|
||||||
if (kv.length === 2) {
|
if (kv.length === 2) {
|
||||||
kva = opt[kv[0]] = opt[kv[0]] || [];
|
kva = opt[kv[0]] = opt[kv[0]] || [];
|
||||||
|
|
@ -413,6 +417,16 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeOpt(opt) {
|
||||||
|
let out = [];
|
||||||
|
Object.keys(opt).forEach(key => {
|
||||||
|
if (key === 'ver') return;
|
||||||
|
let val = opt[key];
|
||||||
|
out.push(encodeURIComponent(key) + "=" + encodeURIComponent(val));
|
||||||
|
});
|
||||||
|
return out.length ? '?' + out.join('&') : '';
|
||||||
|
}
|
||||||
|
|
||||||
function ajax(url, fn, rt, po, hd) {
|
function ajax(url, fn, rt, po, hd) {
|
||||||
return new MOTO.Ajax(fn, rt).request(url, po, hd);
|
return new MOTO.Ajax(fn, rt).request(url, po, hd);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue