From bcad295582e2abeaed22b5636f1ae015c4db8304 Mon Sep 17 00:00:00 2001 From: Tobias Lins Date: Tue, 30 Jan 2024 09:48:21 +0100 Subject: [PATCH] Only return `route` if params is not `null` (#52) --- packages/web/package.json | 2 +- packages/web/src/nextjs/utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/web/package.json b/packages/web/package.json index bf141d6..545098b 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -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", diff --git a/packages/web/src/nextjs/utils.ts b/packages/web/src/nextjs/utils.ts index 5a193c6..ef08210 100644 --- a/packages/web/src/nextjs/utils.ts +++ b/packages/web/src/nextjs/utils.ts @@ -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'; @@ -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; };