api7 / lua-resty-radixtree

Adaptive Radix Trees implemented in Lua / LuaJIT
https://api7.ai/
Apache License 2.0
257 stars 61 forks source link

fix: give more priority to longer routes #145

Closed shreemaan-abhishek closed 9 months ago

shreemaan-abhishek commented 9 months ago

Fixes https://github.com/apache/apisix/issues/9366

Explanation:

when creating different routes that have a common prefix but are differentiated with a parameter, route matching becomes dependent on the registration order.

Consider the case:

uri for route_a: /api/:version/test/api/projects/:project_id/clusters/:cluster_id/nodes/? uri for route_b: /api/:version/test/*subpath

path to be matched: /api/v4/test/api/projects/saas/clusters/123/nodes/

Theoretically, the above path should match route_a but due to the bug if route_b is registered before route_a, route_b will be matched