From 4d5795221c358a80bc22c1933af772cd7686217c Mon Sep 17 00:00:00 2001 From: mikyll Date: Thu, 6 Feb 2025 12:24:44 +0100 Subject: [PATCH 1/2] test: slash parameter - should close api7/lua-resty-radixtree#148 (demonstrates that the issue is not related to this library); - is related to apache/apisix#11810 --- t/parameter.t | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/t/parameter.t b/t/parameter.t index bef6b63..144080e 100644 --- a/t/parameter.t +++ b/t/parameter.t @@ -476,7 +476,7 @@ match meta: medium -=== TEST 14: special characters in parameter should match +=== TEST 14: special characters in parameter should match (space) --- config location /t { content_by_lua_block { @@ -501,4 +501,33 @@ GET /t [error] --- response_body match meta: metadata /name -matched: {"_path":"/name/:name/id","name":"json%20space"} +matched: {"_path":"/name/:name/id","name":"json%2fspace"} + + + +=== TEST 15: special characters in parameter should match (slash) +--- config + location /t { + content_by_lua_block { + local json = require("toolkit.json") + local radix = require("resty.radixtree") + local rx = radix.new({ + { + paths = {"/name/:name/id"}, + metadata = "metadata /name", + }, + }) + + local opts = {matched = {}} + local meta = rx:match("/name/json%2fslash/id", 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 /name +matched: {"_path":"/name/:name/id","name":"json%2fslash"} From 6354bd525273b91cf89c8ad6981afe8ce60b9307 Mon Sep 17 00:00:00 2001 From: mikyll Date: Wed, 30 Apr 2025 12:40:02 +0200 Subject: [PATCH 2/2] test: fix test 14 --- t/parameter.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/parameter.t b/t/parameter.t index 144080e..6a5ab45 100644 --- a/t/parameter.t +++ b/t/parameter.t @@ -501,7 +501,7 @@ GET /t [error] --- response_body match meta: metadata /name -matched: {"_path":"/name/:name/id","name":"json%2fspace"} +matched: {"_path":"/name/:name/id","name":"json%20space"}