Comparing version 1.0.10 to 1.0.11
@@ -116,6 +116,15 @@ "use strict"; | ||
function last (err) { | ||
let errorCode, status; | ||
let last = err => { | ||
let allowed, errorCode, status; | ||
if (!err) { | ||
// Double checking `this.allows()` (middleware memoization) | ||
if (!req.allow) { | ||
allowed = this.allows(req.parsed.pathname, req.host); | ||
if (allowed) { | ||
req.allow = allowed; | ||
} | ||
} | ||
deferred.reject(req.allow.indexOf("GET") > -1 ? new Error(405) : new Error(404)); | ||
@@ -127,3 +136,3 @@ } else { | ||
} | ||
} | ||
}; | ||
@@ -133,17 +142,17 @@ let next = err => { | ||
let arity = 3, | ||
step = middleware.next(); | ||
iter = middleware.next(); | ||
if (!res._header && !step.done) { | ||
if (!res.finished && !iter.done) { | ||
if (err) { | ||
arity = utility.getArity(step.value); | ||
arity = utility.getArity(iter.value); | ||
do { | ||
arity = utility.getArity(step.value); | ||
} while (arity < 4 && (step = middleware.next()) && !step.done); | ||
arity = utility.getArity(iter.value); | ||
} while (arity < 4 && (iter = middleware.next()) && !iter.done); | ||
} | ||
if (!step.done) { | ||
if (!iter.done) { | ||
if (err) { | ||
if (arity === 4) { | ||
try { | ||
step.value(err, req, res, next); | ||
iter.value(err, req, res, next); | ||
} catch (e) { | ||
@@ -157,3 +166,3 @@ next(e); | ||
try { | ||
step.value(req, res, next); | ||
iter.value(req, res, next); | ||
} catch (e) { | ||
@@ -166,3 +175,3 @@ next(e); | ||
} | ||
} else if (!res._header) { | ||
} else if (!res.finished) { | ||
last(err); | ||
@@ -169,0 +178,0 @@ } |
{ | ||
"name": "woodland", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Lightweight HTTP/HTTPS router with virtual hosts", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15168
355