Skip to content

Commit 09d07bf

Browse files
authored
bugfix: return false if not matched the fully request URI. (#52)
1 parent 5b1d055 commit 09d07bf

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

lib/resty/radixtree.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ local function compare_param(req_path, route, opts)
452452
return false
453453
end
454454

455+
if m[0] ~= req_path then
456+
return false
457+
end
458+
455459
if not opts.matched then
456460
return true
457461
end

t/parameter.t

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,44 @@ match meta: metadata /name
235235
match meta: nil
236236
--- error_log
237237
pcre pat:
238+
239+
240+
241+
=== TEST 8: /:name/foo
242+
--- config
243+
location /t {
244+
content_by_lua_block {
245+
local json = require("cjson.safe")
246+
local radix = require("resty.radixtree")
247+
local rx = radix.new({
248+
{
249+
paths = {"/:name/foo"},
250+
metadata = "metadata /:name/foo",
251+
},
252+
})
253+
254+
local opts = {matched = {}}
255+
local meta = rx:match("/json/", opts)
256+
ngx.say("match meta: ", meta)
257+
258+
meta = rx:match("/json/bar", opts)
259+
ngx.say("match meta: ", meta)
260+
261+
meta = rx:match("/json/foo", opts)
262+
ngx.say("match meta: ", meta)
263+
264+
meta = rx:match("/json/foo/bar", opts)
265+
ngx.say("match meta: ", meta)
266+
}
267+
}
268+
--- request
269+
GET /t
270+
--- no_error_log
271+
[error]
272+
--- response_body
273+
match meta: nil
274+
match meta: nil
275+
match meta: metadata /:name/foo
276+
match meta: nil
277+
--- error_log
278+
pcre pat:

0 commit comments

Comments
 (0)