UNPKG

728 BJavaScriptView Raw
1/**
2 * react-router v8.4.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 invariant from "./invariant.js";
12//#region lib/server-runtime/routeMatching.ts
13function matchServerRoutes(manifest, staticHandler, pathname) {
14 let matches = staticHandler.match(pathname);
15 if (!matches) return null;
16 return matches.map((match) => {
17 let route = manifest[match.route.id];
18 invariant(route, `Route with id "${match.route.id}" not found in manifest.`);
19 return {
20 params: match.params,
21 pathname: match.pathname,
22 route
23 };
24 });
25}
26//#endregion
27export { matchServerRoutes };