lua-resty-radixtree
lua-resty-radixtree copied to clipboard
bug: path parameter matching
When setting the route as "/api/:upload_id/info", the following request cannot be matched
/api/DCAppFile_2~9lwcn8WIw6sqq2v_Z7Wd6kLIfAhKVb0-MRKUYR2WMJKUUVTZKVLXOZKVLBXE65SOG5IUW52IOAZEE6JRNRIHEUSNOYXWI3RTJFLXEZKPJ5KU2VKIPBCHK3JUPJIUOTJSMJZECR2RPJVG643JM5YFEZLHON4XIU3Y-6XBBIO35THB6WGDDKZ63LJTWX2LVPM42PPC6RNJUNDNZB6J422ADLEQ6DVXSR2FBCWUX2TCYZASWQNRXFJ5O63KHLBHHEOEK-AES_256_ECB-1c3b94db/info
How should this be handled?
I ran the following test case and it passed (resty-radixtree matches it correctly), which suggests the issue is not related to lua-resty-radixtree. Could you provide additional details? Examples:
- how are you testing that route;
- which version are you using (of apisix and lua-resty-radixtree);
- what is the route configuration;
- access/error logs;
Test
File t/long_path_param.t:
# vim:set ft= ts=4 sw=4 et fdm=marker:
use t::RX 'no_plan';
repeat_each(1);
run_tests();
__DATA__
=== TEST: long path parameter
--- config
location /t {
content_by_lua_block {
local json = require("toolkit.json")
local radix = require("resty.radixtree")
local rx = radix.new({
{
paths = {"/api/:upload_id/info"},
metadata = "metadata /api",
},
})
local opts = {matched = {}}
local meta = rx:match("/api/DCAppFile_2~9lwcn8WIw6sqq2v_Z7Wd6kLIfAhKVb0-MRKUYR2WMJKUUVTZKVLXOZKVLBXE65SOG5IUW52IOAZEE6JRNRIHEUSNOYXWI3RTJFLXEZKPJ5KU2VKIPBCHK3JUPJIUOTJSMJZECR2RPJVG643JM5YFEZLHON4XIU3Y-6XBBIO35THB6WGDDKZ63LJTWX2LVPM42PPC6RNJUNDNZB6J422ADLEQ6DVXSR2FBCWUX2TCYZASWQNRXFJ5O63KHLBHHEOEK-AES_256_ECB-1c3b94db/info", opts)
ngx.say("match meta: ", meta)
ngx.say("matched: ", json.encode(opts.matched))
}
}
--- request
GET /t
--- no_error_log
[error]
--- response_body
match meta: metadata /api
matched: {"_path":"/api/:upload_id/info","upload_id":"DCAppFile_2~9lwcn8WIw6sqq2v_Z7Wd6kLIfAhKVb0-MRKUYR2WMJKUUVTZKVLXOZKVLBXE65SOG5IUW52IOAZEE6JRNRIHEUSNOYXWI3RTJFLXEZKPJ5KU2VKIPBCHK3JUPJIUOTJSMJZECR2RPJVG643JM5YFEZLHON4XIU3Y-6XBBIO35THB6WGDDKZ63LJTWX2LVPM42PPC6RNJUNDNZB6J422ADLEQ6DVXSR2FBCWUX2TCYZASWQNRXFJ5O63KHLBHHEOEK-AES_256_ECB-1c3b94db"}
Test run:
prove -Itest-nginx/lib -I. -r t/long_path_param.t
t/long_path_param.t .. ok
All tests successful.
Files=1, Tests=3, 1 wallclock secs ( 0.02 usr 0.00 sys + 0.08 cusr 0.02 csys = 0.12 CPU)
Result: PASS