Skip to content

Commit 11f7b4e

Browse files
authored
bugfix: got error when match var and have no uri args (#40)
1 parent 2676ca6 commit 11f7b4e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/resty/radixtree.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ local function match_route_opts(route, opts, ...)
599599
l_v = vars[l_v]
600600

601601
-- ngx.log(ngx.INFO, l_v, op, r_v)
602+
if l_v == nil or r_v == nil then
603+
return false
604+
end
602605
if not compare_val(l_v, op, r_v, opts) then
603606
return false
604607
end

t/vars.t

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,30 @@ nil
445445
nil
446446
nil
447447
nil
448+
449+
450+
451+
=== TEST 16: have no uri args
452+
--- config
453+
location /t {
454+
content_by_lua_block {
455+
local radix = require("resty.radixtree")
456+
local rx = radix.new({
457+
{
458+
paths = "/aa",
459+
metadata = "metadata /aa",
460+
vars = {
461+
{"arg_k", ">", 10},
462+
},
463+
}
464+
})
465+
466+
ngx.say(rx:match("/aa", {vars = {}}))
467+
}
468+
}
469+
--- request
470+
GET /t
471+
--- no_error_log
472+
[error]
473+
--- response_body
474+
nil

0 commit comments

Comments
 (0)