Skip to content

Commit

Permalink
Fixing route() such that result.params is evaluated correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Dec 26, 2020
1 parent dc12ace commit 489a29a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/woodland.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,10 @@ class Woodland extends EventEmitter {
}

route (...args) {
const [req, res] = args;
const [req, res] = args,
e = err => this.emit("error", req, res, err);
let method = req.method === "HEAD" ? "GET" : req.method;

const e = err => this.emit("error", req, res, err);

this.emit("connect", req, res);
res.on("finish", () => this.emit("finish", req, res));

Expand All @@ -228,7 +227,7 @@ class Woodland extends EventEmitter {
} else if (req.allow.includes(method)) {
const result = this.routes(req.parsed.pathname, method);

if (result.params !== void 0) {
if (result.params) {
params(req, result.pos);
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woodland",
"version": "11.0.0",
"version": "11.0.1",
"description": "Lightweight HTTP/HTTP2 router with automatic headers",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 489a29a

Please sign in to comment.