Skip to content

Commit

Permalink
bugfix: return false if not matched the fully request URI. (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
membphis authored Aug 14, 2020
1 parent 5b1d055 commit 09d07bf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/resty/radixtree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ local function compare_param(req_path, route, opts)
return false
end

if m[0] ~= req_path then
return false
end

if not opts.matched then
return true
end
Expand Down
41 changes: 41 additions & 0 deletions t/parameter.t
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,44 @@ match meta: metadata /name
match meta: nil
--- error_log
pcre pat:
=== TEST 8: /:name/foo
--- config
location /t {
content_by_lua_block {
local json = require("cjson.safe")
local radix = require("resty.radixtree")
local rx = radix.new({
{
paths = {"/:name/foo"},
metadata = "metadata /:name/foo",
},
})
local opts = {matched = {}}
local meta = rx:match("/json/", opts)
ngx.say("match meta: ", meta)
meta = rx:match("/json/bar", opts)
ngx.say("match meta: ", meta)
meta = rx:match("/json/foo", opts)
ngx.say("match meta: ", meta)
meta = rx:match("/json/foo/bar", opts)
ngx.say("match meta: ", meta)
}
}
--- request
GET /t
--- no_error_log
[error]
--- response_body
match meta: nil
match meta: nil
match meta: metadata /:name/foo
match meta: nil
--- error_log
pcre pat:

0 comments on commit 09d07bf

Please sign in to comment.