Skip to content

Commit

Permalink
fix: fix some internal matchRoutes
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 27, 2023
1 parent d8efd2e commit 2e42c32
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/remix-dev/vite/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export const getStylesForUrl = async (

let routes = createRoutes(build.routes);
let appPath = path.relative(process.cwd(), config.appDirectory);
// TODO: basename
let documentRouteFiles =
matchRoutes(routes, url)?.map((match) =>
path.join(appPath, config.routes[match.route.id].file)
Expand Down
8 changes: 6 additions & 2 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export function PrefetchPageLinks({
}: PrefetchPageDescriptor) {
let { router } = useDataRouterContext();
let matches = React.useMemo(
() => matchRoutes(router.routes, page),
() => matchRoutes(router.routes, page, router.basename),
[router.routes, page]
);

Expand Down Expand Up @@ -833,7 +833,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
let nextMatches = React.useMemo(() => {
if (navigation.location) {
// FIXME: can probably use transitionManager `nextMatches`
let matches = matchRoutes(router.routes, navigation.location);
let matches = matchRoutes(
router.routes,
navigation.location,
router.basename
);
invariant(
matches,
`No routes match path "${navigation.location.pathname}"`
Expand Down
1 change: 1 addition & 0 deletions packages/remix-server-runtime/routeMatching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function matchServerRoutes(
routes: ServerRoute[],
pathname: string
): RouteMatch<ServerRoute>[] | null {
// TODO: basename
let matches = matchRoutes(
routes as unknown as AgnosticRouteObject[],
pathname
Expand Down

0 comments on commit 2e42c32

Please sign in to comment.