mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00
refactor(app.js): Extract middleware to module
extract check URi is valid, redirect without trailing slashes
This commit is contained in:
parent
7ba0d600f1
commit
dee77c459a
3 changed files with 33 additions and 20 deletions
14
lib/web/middleware/checkURiValid.js
Normal file
14
lib/web/middleware/checkURiValid.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
'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()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue