Skip to content

Commit

Permalink
Only return route if params is not null (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiaslins authored Jan 30, 2024
1 parent fa990dd commit bcad295
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vercel/speed-insights",
"version": "1.0.8",
"version": "1.0.9",
"description": "Speed Insights is a tool for measuring web performance and providing suggestions for improvement.",
"keywords": [
"speed-insights",
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/nextjs/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
/* eslint-disable @typescript-eslint/no-unnecessary-condition -- can be empty in pages router */
import { useParams, usePathname, useSearchParams } from 'next/navigation.js';
import { computeRoute } from '../utils';

Expand All @@ -9,9 +10,8 @@ export const useRoute = (): string | null => {

const finalParams = {
...Object.fromEntries(searchParams.entries()),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- can be empty in pages router
...(params || {}),
};

return computeRoute(path, finalParams);
return params ? computeRoute(path, finalParams) : null;
};

0 comments on commit bcad295

Please sign in to comment.