From 91c16d1e24a4f62c1bf5b460931d240453c6b000 Mon Sep 17 00:00:00 2001 From: TJ Borromeo Date: Fri, 24 Apr 2015 15:06:34 -0700 Subject: [PATCH] Remove unnecessary if statements nil is false in lua, just utilizing that fact. --- httpserver-request.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpserver-request.lua b/httpserver-request.lua index 638dc7a..3384667 100644 --- a/httpserver-request.lua +++ b/httpserver-request.lua @@ -4,7 +4,8 @@ local function validateMethod(method) local httpMethods = {GET=true, HEAD=true, POST=true, PUT=true, DELETE=true, TRACE=true, OPTIONS=true, CONNECT=true, PATCH=true} - if httpMethods[method] then return true else return false end + -- default for non-existent attributes returns nil, which evaluates to false + return httpMethods[method] end local function uriToFilename(uri)