Decode URI

This commit is contained in:
MrFry 2019-11-18 17:18:12 +01:00
parent bbbf42b685
commit 62a0e3fbc9

View file

@ -52,7 +52,7 @@ app.use(bodyParser.json({
// app, '/*.mp4', 'video/mp4', 'stuff/video' // app, '/*.mp4', 'video/mp4', 'stuff/video'
function appGetFileType (app, wildcard, contentType, pageToRender) { function appGetFileType (app, wildcard, contentType, pageToRender) {
app.get(wildcard, function (req, res) { app.get(wildcard, function (req, res) {
let p = req.url.replace(/%20/g, ' ') let p = decodeURI(req.url)
let fp = p let fp = p
if (p.includes('?')) { if (p.includes('?')) {
fp = p.split('?') fp = p.split('?')
@ -131,7 +131,7 @@ fileTypes.forEach((t) => {
}) })
app.get('/*', function (req, res) { app.get('/*', function (req, res) {
let parsedUrl = req.url.replace(/%20/g, ' ') let parsedUrl = decodeURI(req.url)
let curr = listedFiles + '/' + parsedUrl.substring('/'.length, parsedUrl.length).split('?')[0] let curr = listedFiles + '/' + parsedUrl.substring('/'.length, parsedUrl.length).split('?')[0]
let relPath = curr.substring('./public/files'.length, curr.length) let relPath = curr.substring('./public/files'.length, curr.length)