hedgedoc/old_src/lib/web/middleware/checkURIValid.ts
David Mehren 7b9f9a487b
Move old backend code to old_src folder
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:43:05 +02:00

13 lines
348 B
TypeScript

import { logger } from '../../logger'
import { errors } from '../../errors'
import { NextFunction, Request, Response } from 'express'
export function checkURI (req: Request, res: Response, next: NextFunction): void {
try {
decodeURIComponent(req.path)
next()
} catch (err) {
logger.error(err)
errors.errorBadRequest(res)
}
}