lua-radix-router icon indicating copy to clipboard operation
lua-radix-router copied to clipboard

`trailing_slash_match` does not work when another subpath is routable

Open Dr-Emann opened this issue 6 months ago • 1 comments

local Router = require "radix-router"
local options = {
    trailing_slash_match = true,
}

local router = Router.new({
    {
        paths = { "/{placeholder}/a" },
        handler = "route1",
    },
    {
        paths = { "/{placeholder}/a/sub" },
        handler = "route2",
    }
}, options)

assert("route1" == router:match("/value/a/")) -- Fails
assert("route2" == router:match("/value/a/sub/")) -- Succeeds

I expected /value/a/ to match against the /{placeholder}/a router path, as /value/a/sub/ matches against the /{placeholder}/a/sub router path.

Dr-Emann avatar Jun 26 '25 19:06 Dr-Emann

Possibly related to #48

Dr-Emann avatar Jun 26 '25 19:06 Dr-Emann