From 5d17ec8cf7480ad3d34a1d2d4b06b3a406c1529a Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 17 Nov 2019 00:05:50 +0100 Subject: Deal with encoded URL --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 71ad164..79c8085 100644 --- a/app.js +++ b/app.js @@ -98,7 +98,7 @@ app.get('/', (req, res) => { app.get('/edit/?*', (req, res) => { console.log(`[${new Date()}] > ${200} - ${req.url}`); - const pathReq = path.normalize(`md/${req.url.slice(5)}`); + const pathReq = decodeURIComponent(path.normalize(`md/${req.url.slice(5)}`)); console.log(`[${new Date()}] > ${200} - ${pathReq}`); @@ -111,7 +111,7 @@ app.get('/edit/?*', (req, res) => { }); }); app.put('/edit/?*', (req, res) => { - const pathR = path.normalize(`md${req.url.slice(5)}`); + const pathR = decodeURIComponent(path.normalize(`md${req.url.slice(5)}`)); console.log('PUT !'); console.log(pathR); if (pathR.startsWith('md/public') || -- cgit v1.2.3