parent
3095cff7d9
commit
e7ddcb91fc
@ -3,6 +3,7 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const PACKAGE = require('../../../package.json');
|
const PACKAGE = require('../../../package.json');
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
const router = express.Router({
|
const router = express.Router({
|
||||||
caseSensitive: true,
|
caseSensitive: true,
|
||||||
@ -29,15 +30,22 @@ router.get(/(.*)/, function (req, res, next) {
|
|||||||
version: PACKAGE.version
|
version: PACKAGE.version
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
fs.readFile('dist' + req.params.page, 'utf8', function (err, data) {
|
var p = path.normalize('dist' + req.params.page)
|
||||||
if (err) {
|
if (p.startsWith('dist')) { // Allow access to ressources under 'dist' directory only.
|
||||||
res.render('index', {
|
fs.readFile(p, 'utf8', function (err, data) {
|
||||||
version: PACKAGE.version
|
if (err) {
|
||||||
});
|
res.render('index', {
|
||||||
} else {
|
version: PACKAGE.version
|
||||||
res.contentType('text/html').end(data);
|
});
|
||||||
}
|
} else {
|
||||||
});
|
res.contentType('text/html').end(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.render('index', {
|
||||||
|
version: PACKAGE.version
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user