forbid now uses path-to-regexp paths.. docs.. rewrite examples

This commit is contained in:
Lloyd Brookes
2015-11-17 11:18:25 +00:00
parent 7a991cc5f7
commit b3de999e4d
11 changed files with 73 additions and 19 deletions

View File

@ -129,9 +129,7 @@ function localWebServer (options) {
function logstalgiaDate () {
var d = new Date()
return (`${d.getDate()}/${d.getUTCMonth()}/${d.getFullYear()}:${d.toTimeString()}`)
.replace('GMT', '')
.replace(' (BST)', '')
return (`${d.getDate()}/${d.getUTCMonth()}/${d.getFullYear()}:${d.toTimeString()}`).replace('GMT', '').replace(' (BST)', '')
}
function proxyRequest (route) {
@ -174,7 +172,7 @@ function proxyRequest (route) {
function blacklist (forbid) {
return function blacklist (ctx, next) {
if (forbid.some(regexp => regexp.test(ctx.path))) {
if (forbid.some(expression => pathToRegexp(expression).test(ctx.path))) {
ctx.throw(403, http.STATUS_CODES[403])
} else {
return next()