koa-path-validation

1.0.1 • Public • Published

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();
}

Package Sidebar

Install

npm i koa-path-validation

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

2.33 kB

Total Files

4

Last publish

Collaborators

  • leecjson