@@ -189,7 +189,7 @@ matched: {}
189189 local opts = {matched = {}, method = "GET", host = "aa.bar.com"}
190190 local meta = rx:match("/bb/cc/xx", opts)
191191 ngx.say("match meta: ", meta)
192- ngx.say("matched: ", json.encode(opts.matched))
192+ ngx.say("matched: ", json.encode(opts.matched))
193193
194194 }
195195 }
@@ -203,15 +203,15 @@ matched: {"_path":"\/bb\/cc\/*",":ext":"xx","_method":"GET","_host":"*.bar.com"}
203203
204204
205205
206- === TEST 7: /name/*name/foo
206+ === TEST 7: /name/*name/foo (cached parameter)
207207--- config
208208 location /t {
209209 content_by_lua_block {
210210 local json = require("cjson.safe")
211211 local radix = require("resty.radixtree")
212212 local rx = radix.new({
213213 {
214- paths = {"/name/* name/foo"},
214+ paths = {"/name/: name/foo"},
215215 metadata = "metadata /name",
216216 },
217217 })
@@ -232,6 +232,36 @@ GET /t
232232[error]
233233--- response_body
234234match meta: metadata /name
235- matched: {"_path":"\/name\/* name\/foo","name":"json"}
235+ matched: {"_path":"\/name\/: name\/foo","name":"json"}
236236match meta: nil
237237matched: {}
238+
239+
240+
241+ === TEST 8: /name/*name/foo (no cached parameter)
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/:name/foo"},
250+ metadata = "metadata /name",
251+ },
252+ })
253+
254+ local opts = {}
255+ local meta = rx:match("/name/json/foo", opts)
256+ ngx.say("match meta: ", meta)
257+ meta = rx:match("/name/json", opts)
258+ ngx.say("match meta: ", meta)
259+ }
260+ }
261+ --- request
262+ GET /t
263+ --- no_error_log
264+ [error]
265+ --- response_body
266+ match meta: metadata /name
267+ match meta: nil
0 commit comments