Skip to content

Commit

Permalink
avoid the void
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Sep 6, 2022
1 parent cda4b9f commit 53b5021
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/nextjs/src/performance/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,18 @@ export function nextRouterInstrumentation(
}
}

function getNextRouteFromPathname(pathname: string): string | void {
function getNextRouteFromPathname(pathname: string): string | undefined {
const pageRoutes = (global.__BUILD_MANIFEST || {}).sortedPages;

// Page route should in 99.999% of the cases be defined by now but just to be sure we make a check here
if (pageRoutes) {
return pageRoutes.find(route => {
const routeRegExp = convertNextRouteToRegExp(route);
return pathname.match(routeRegExp);
});
if (!pageRoutes) {
return;
}

return pageRoutes.find(route => {
const routeRegExp = convertNextRouteToRegExp(route);
return pathname.match(routeRegExp);
});
}

/**
Expand Down

0 comments on commit 53b5021

Please sign in to comment.