From eb51556e88fbc111e61d27a1939d80679cf38512 Mon Sep 17 00:00:00 2001 From: David Murdoch Date: Wed, 26 Feb 2025 01:15:38 +0000 Subject: [PATCH] chore: use set in api/locate * Set has an O notation of O(1) * https://www.youtube.com/watch?v=zSeGG-SCm8s --- src/app/(frontend)/api/locate/route.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/(frontend)/api/locate/route.ts b/src/app/(frontend)/api/locate/route.ts index 0522bd876..cd2df704a 100644 --- a/src/app/(frontend)/api/locate/route.ts +++ b/src/app/(frontend)/api/locate/route.ts @@ -1,4 +1,4 @@ -const gdprCountryCodes = [ +const gdprCountryCodes = new Set([ // -----[ EU 28 ]----- 'AT', // Austria 'BE', // Belgium @@ -75,14 +75,14 @@ const gdprCountryCodes = [ // -----[ Other ]----- 'JE', // Jersey 'GG', // Guernsey -] +]) /** * Returns the status of GDPR requirement and defaults to true when unknown * @param countryCode */ const locate = (countryCode: null | string = null): boolean => - countryCode ? gdprCountryCodes.indexOf(countryCode) > -1 : true + countryCode ? gdprCountryCodes.has(countryCode) : true export function GET(req: Request) { const country = req.headers.get('x-vercel-ip-country')