An open API service indexing awesome lists of open source software.

https://github.com/leecjson/koa-path-validation

Validate koa's ctx.path
https://github.com/leecjson/koa-path-validation

Last synced: 16 days ago
JSON representation

Validate koa's ctx.path

Awesome Lists containing this project

README

          

# Start
```
npm i --save koa-path-validation
```

# Source code
```javascript
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();
}
```