Closed pi0 closed 7 months ago
It seems that /
(slash) is incorrectly ignored in the wildcard route. /c/**
matches everything starting with "c"
Reproduction:
const { createRouter, toRouteMatcher } = require("radix3");
const router = createRouter();
router.insert("/c/**", { name: "c/**" });
router.insert("/cart", { name: "a" });
const matcher = toRouteMatcher(router);
// BUG: Should return empty array
console.log(matcher.matchAll("/cAnything"));
// Example from README.md
const router2 = createRouter({
routes: {
"/foo": { m: "foo" }, // Matches /foo only
"/foo/**": { m: "foo/**" }, // Matches /foo/<any>
"/foo/bar": { m: "foo/bar" }, // Matches /foo/bar only
"/foo/bar/baz": { m: "foo/bar/baz" }, // Matches /foo/bar/baz only
"/foo/*/baz": { m: "foo/*/baz" }, // Matches /foo/<any>/baz
},
});
const matcher2 = toRouteMatcher(router2);
// BUG: Should return empty array
console.log(matcher2.matchAll("/foobarbaz"))
Context: https://github.com/nuxt/nuxt/issues/24107
Radix 3 version: 1.1.0 and main
[{ name: 'a' }]
[{name: '/c/**' }, { name: 'a' }]