1.0.1 • Published 5 years ago
koa-path-validation v1.0.1
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();
}