11 lines
287 B
JavaScript
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
|
|
};
|