From 6da61b973b8257f67be7b872bff82ecd2cb291a7 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Fri, 20 Mar 2020 12:03:20 -0400 Subject: [PATCH] a couple of patches for windows, edge, and debugging mode --- js/kiri.js | 2 +- js/web-server.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/js/kiri.js b/js/kiri.js index fd06e0fa..bc17e808 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -372,7 +372,7 @@ self.kiri.copyright = exports.COPYRIGHT; function parseOpt(ov) { var opt = {}, kv, kva; // handle kiri legacy and proper url encoding better - ov.split(',').map(v => v.split('&')).flat(1).forEach(function(el) { + ov.replace(/&/g,',').split(',').forEach(function(el) { kv = decodeURIComponent(el).split(':'); if (kv.length === 2) { kva = opt[kv[0]] = opt[kv[0]] || []; diff --git a/js/web-server.js b/js/web-server.js index 6a1838c1..ceebded9 100644 --- a/js/web-server.js +++ b/js/web-server.js @@ -188,7 +188,10 @@ function concatCode(array) { if (file.indexOf(".js") < 0) { file = `/js/${file}.js`; } - code.push(`"${file}",`); + if (file.indexOf(":\\") > 0) { + file = `/${file}`; + } + code.push(`"${file.replace(/\\/g,'/')}",`); }); code.push([ ']; function load_next() {', @@ -447,8 +450,12 @@ function addCorsHeaders(req, res) { * in debug mode only, serve ANY file path beginning with / that exists */ function handleDebug(req, res, next) { - if (debug && lastmod(req.url)) { - return res.end(fs.readFileSync(req.url)); + if (debug) { + if (lastmod(req.url)) { + return res.end(fs.readFileSync(req.url)); + } else if (lastmod(req.url.substring(1))) { + return res.end(fs.readFileSync(req.url.substring(1))); + } } return next(); }