Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marklawlor committed Mar 4, 2024
1 parent 145a377 commit 6968551
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/expo-router/src/getRoutes.ts
Expand Up @@ -186,7 +186,7 @@ function getDirectoryTree(contextModule: RequireContext, options: Options) {
directory.files.set(fileKey, nodes);
}

// TODO(Platform Route): Throw error if specificity > 0, as you cannot specify platform extensions for api routes
// API Routes have no specificity, they are always the first node
const existing = nodes[0];

if (existing) {
Expand Down Expand Up @@ -364,9 +364,9 @@ function getFileMeta(key: string, options: Options) {
} else if (platformExtension === 'native' && options.platform !== 'web') {
// `native` is allow but isn't as specific as the platform
specificity = 1;
} else if (options.platform) {
// If we have a platform, then we should ignore the other platform extensions
// We might not have a platform if we are generating the routes for the sitemap, typed routes, etc
} else if (platformExtension !== options.platform) {
// Somehow we have a platform extension that doesn't match the options.platform and it isn't native
// This is an invalid file and we will ignore it
specificity = -1;
}

Expand Down Expand Up @@ -605,5 +605,7 @@ function getMostSpecific(routes: RouteNode[]) {
);
}

// This works even tho routes is holey array (e.g it might have index 0 and 2 but not 1)
// `.length` includes the holes in its count
return routes[routes.length - 1];
}

0 comments on commit 6968551

Please sign in to comment.