UNPKG

841 BJavaScriptView Raw
1/**
2 * react-router v8.0.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 */
11import { matchRoutesImpl } from "../router/utils.js";
12import invariant from "./invariant.js";
13//#region lib/server-runtime/routeMatching.ts
14function 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//#endregion
28export { matchServerRoutes };