Browse Source

Remove unnecessary if statements

nil is false in lua, just utilizing that fact.
TJ Borromeo 9 years ago
parent
commit
91c16d1e24
1 changed files with 2 additions and 1 deletions
  1. 2 1
      httpserver-request.lua

+ 2 - 1
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)