| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 |
|
| 11 | import { flattenAndRankRoutes, matchRoutesImpl } from "./utils.js";
|
| 12 |
|
| 13 | var V6RegExMatcher = class {
|
| 14 | #routes = [];
|
| 15 | #branches = [];
|
| 16 | #basename;
|
| 17 | #matchCost = 0;
|
| 18 | constructor(basename) {
|
| 19 | this.#basename = basename;
|
| 20 | }
|
| 21 | update(routes) {
|
| 22 | this.#routes = routes;
|
| 23 | this.#branches = flattenAndRankRoutes(routes);
|
| 24 | this.#matchCost = this.#branches.reduce((total, branch) => total + branch.routesMeta.length, 0);
|
| 25 | }
|
| 26 | get matchCost() {
|
| 27 | return this.#matchCost;
|
| 28 | }
|
| 29 | match(locationArg, allowPartial = false) {
|
| 30 | return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
|
| 31 | }
|
| 32 | };
|
| 33 |
|
| 34 | export { V6RegExMatcher };
|