| 1 | |
| 2 | * react-router v8.3.0
|
| 3 | *
|
| 4 | * Copyright (c) Remix Software Inc.
|
| 5 | *
|
| 6 | * This source code is licensed under the MIT license found in the
|
| 7 | * LICENSE.md file in the root directory of this source tree.
|
| 8 | *
|
| 9 | * @license MIT
|
| 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 };
|