koa-path-validation
v1.0.1
Published
Validate koa's ctx.path
Downloads
10
Maintainers
Readme
Start
npm i --save koa-path-validation
Source code
module.exports = async (ctx, next) => {
if (ctx.path.startsWith('./') || ctx.path.startsWith('../') ||
ctx.path.indexOf('/./') > 0 || ctx.path.indexOf('/../') > 0 || ctx.path.indexOf('\0') > 0) {
ctx.throw(403);
}
await next();
}