blacklist tests
This commit is contained in:
@ -21,7 +21,8 @@ function getApp (options) {
|
||||
static: {},
|
||||
serveIndex: {},
|
||||
log: {},
|
||||
compress: false
|
||||
compress: false,
|
||||
blacklist: []
|
||||
}, options)
|
||||
|
||||
const log = options.log
|
||||
@ -33,13 +34,15 @@ function getApp (options) {
|
||||
app.use(convert(cors()))
|
||||
|
||||
/* path blacklist */
|
||||
app.use(function pathBlacklist (ctx, next) {
|
||||
if (/css$/.test(ctx.path)) {
|
||||
ctx.throw(403, 'FUCK NO.')
|
||||
} else {
|
||||
return next()
|
||||
}
|
||||
})
|
||||
if (options.blacklist.length) {
|
||||
app.use(function pathBlacklist (ctx, next) {
|
||||
if (options.blacklist.some(regexp => regexp.test(ctx.path))) {
|
||||
ctx.throw(403, 'Blacklisted')
|
||||
} else {
|
||||
return next()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
app.use(convert(conditional()))
|
||||
app.use(convert(etag()))
|
||||
|
Reference in New Issue
Block a user