From ec9ffbd6ba4633784a3fd716cc29d6d084975bb7 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 1 Jun 2020 23:24:03 -0400 Subject: [PATCH] reencode url to remove ver --- js/kiri.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/kiri.js b/js/kiri.js index 2f2adf26..860c4aa9 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -65,6 +65,9 @@ self.kiri.copyright = exports.COPYRIGHT; if (SETUP.rm) renderMode = parseInt(SETUP.rm[0]); DBUG.enable(); + // remove version, preserve other settings + WIN.history.replaceState({},'','/kiri/' + encodeOpt(SETUP) + LOC.hash); + // add show() to catalog for API CATALOG.show = showCatalog; @@ -404,6 +407,7 @@ self.kiri.copyright = exports.COPYRIGHT; let opt = {}, kv, kva; // handle kiri legacy and proper url encoding better ov.replace(/&/g,',').split(',').forEach(function(el) { + el = el.replace(/=/g,':'); kv = decodeURIComponent(el).split(':'); if (kv.length === 2) { kva = opt[kv[0]] = opt[kv[0]] || []; @@ -413,6 +417,16 @@ self.kiri.copyright = exports.COPYRIGHT; 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) { return new MOTO.Ajax(fn, rt).request(url, po, hd); }