| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 |
|
| 11 | import { matchRoutesImpl } from "../router/utils.js";
|
| 12 | import invariant from "./invariant.js";
|
| 13 |
|
| 14 | function matchServerRoutes(manifest, dataRoutes, branches, pathname, basename) {
|
| 15 | let matches = matchRoutesImpl(dataRoutes, pathname, basename ?? "/", false, branches);
|
| 16 | if (!matches) return null;
|
| 17 | return matches.map((match) => {
|
| 18 | let route = manifest[match.route.id];
|
| 19 | invariant(route, `Route with id "${match.route.id}" not found in manifest.`);
|
| 20 | return {
|
| 21 | params: match.params,
|
| 22 | pathname: match.pathname,
|
| 23 | route
|
| 24 | };
|
| 25 | });
|
| 26 | }
|
| 27 |
|
| 28 | export { matchServerRoutes };
|