Skip to content

Commit

Permalink
Merge pull request alexazhou#215 from NeverBehave/patch-1
Browse files Browse the repository at this point in the history
Fix: !Exist does not work issue
  • Loading branch information
alexazhou authored Sep 26, 2018
2 parents ed04f77 + b248ee5 commit 78e275e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions verynginx/lua_script/module/request_tester.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function _M.test_var( match_operator, match_value, target_var )
return false
end


--test a group of var in table with a condition
function _M.test_many_var( var_table, condition )

Expand All @@ -76,10 +75,18 @@ function _M.test_many_var( var_table, condition )
local operator = condition['operator']
local value = condition['value']

for k, v in pairs(var_table) do
if test_var( name_operator, name_value, k ) == true then
if test_var( operator, value, v ) == true then -- if any one value match the condition, means the matcher has been hited
return true
-- Insert !Exist Check here as it is only applied to operator
if operator == '!Exist' then
if var_table[name_value] == nil then
return true
end
else
-- Normal process
for k, v in pairs(var_table) do
if test_var( name_operator, name_value, k ) == true then
if test_var( operator, value, v ) == true then -- if any one value match the condition, means the matcher has been hited
return true
end
end
end
end
Expand Down

0 comments on commit 78e275e

Please sign in to comment.