hedgedoc/lib/web/middleware/checkURiValid.js
BoHong Li dee77c459a refactor(app.js): Extract middleware to module
extract check URi is valid, redirect without trailing slashes
2017-05-08 19:24:37 +08:00

14 lines
279 B
JavaScript

'use strict'
const logger = require('../../logger')
const response = require('../../response')
module.exports = function (req, res, next) {
try {
decodeURIComponent(req.path)
} catch (err) {
logger.error(err)
return response.errorBadRequest(res)
}
next()
}