From 727a76ebb5e8afb24ea4c5aacd1dac34767f075d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 13 Jan 2018 23:29:41 -0500 Subject: [PATCH] fall through to 404 if no handler exists for method --- lib/index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/index.js b/lib/index.js index fae7d30..b104c9d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -174,18 +174,19 @@ function get_route_handler(fn) { res.end(page); } + + return; } - else { - const method = req.method.toLowerCase(); - // 'delete' cannot be exported from a module because it is a keyword, - // so check for 'del' instead - const method_export = method === 'delete' ? 'del' : method; - const handler = mod[method_export]; - if (handler) handler(req, res, next); + const method = req.method.toLowerCase(); + // 'delete' cannot be exported from a module because it is a keyword, + // so check for 'del' instead + const method_export = method === 'delete' ? 'del' : method; + const handler = mod[method_export]; + if (handler) { + handler(req, res, next); + return; } - - return; } }