20 lines
594 B
Plaintext
20 lines
594 B
Plaintext
import "../../router.js";
|
|
//#region src/router/reg-exp-router/matcher.ts
|
|
const emptyParam = [];
|
|
function match(method, path) {
|
|
const matchers = this.buildAllMatchers();
|
|
const match = ((method, path) => {
|
|
const matcher = matchers[method] || matchers["ALL"];
|
|
const staticMatch = matcher[2][path];
|
|
if (staticMatch) return staticMatch;
|
|
const match = path.match(matcher[0]);
|
|
if (!match) return [[], emptyParam];
|
|
const index = match.indexOf("", 1);
|
|
return [matcher[1][index], match];
|
|
});
|
|
this.match = match;
|
|
return match(method, path);
|
|
}
|
|
//#endregion
|
|
export { emptyParam, match };
|