added back logic to strip leading slashes, but after the fix to app.all

This commit is contained in:
Julian Lam
2017-07-25 13:50:37 -04:00
parent 6087f3c8cd
commit c9c27b86c4
2 changed files with 14 additions and 7 deletions

View File

@@ -34,6 +34,15 @@ require('./maintenance')(middleware);
require('./user')(middleware);
require('./headers')(middleware);
middleware.stripLeadingSlashes = function (req, res, next) {
var target = req.originalUrl.replace(nconf.get('relative_path'), '');
if (target.startsWith('//')) {
res.redirect(nconf.get('relative_path') + target.replace(/^\/+/, '/'));
} else {
next();
}
};
middleware.pageView = function (req, res, next) {
analytics.pageView({
ip: req.ip,