@@ -256,7 +256,7 @@ local pre_insert_route
256256do
257257 local route_opts = {}
258258
259- function pre_insert_route (self , path , route )
259+ function pre_insert_route (self , path , route , global_opts )
260260 if type (path ) ~= " string" then
261261 error (" invalid argument path" , 2 )
262262 end
@@ -319,7 +319,7 @@ function pre_insert_route(self, path, route)
319319 route_opts .path_org = path
320320 route_opts .param = false
321321
322- local pos = str_find (path , ' :' , 1 , true )
322+ local pos = not global_opts . no_param_match and str_find (path , ' :' , 1 , true )
323323 if pos then
324324 path = path :sub (1 , pos - 1 )
325325 route_opts .path_op = " <="
@@ -361,11 +361,19 @@ end
361361end -- do
362362
363363
364- function _M .new (routes )
364+ local default_global_opts = {
365+ no_param_match = false ,
366+ }
367+
368+ function _M .new (routes , opts )
365369 if not routes then
366370 return nil , " missing argument route"
367371 end
368372
373+ if not opts then
374+ opts = default_global_opts
375+ end
376+
369377 local route_n = # routes
370378
371379 local tree = radix .radix_tree_new ()
@@ -387,11 +395,11 @@ function _M.new(routes)
387395 local route = routes [i ]
388396 local paths = route .paths
389397 if type (paths ) == " string" then
390- pre_insert_route (self , paths , route )
398+ pre_insert_route (self , paths , route , opts )
391399
392400 else
393401 for _ , path in ipairs (paths ) do
394- pre_insert_route (self , path , route )
402+ pre_insert_route (self , path , route , opts )
395403 end
396404 end
397405 end
0 commit comments