Files
2026-02-05 15:27:49 +08:00

11 lines
287 B
JavaScript

function routeMatcher(paths) {
const regexes = paths.map(
(path) => path.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")
);
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})[^/]*$`;
return new RegExp(regex, "i");
}
export {
routeMatcher
};