Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/(frontend)/api/locate/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const gdprCountryCodes = [
const gdprCountryCodes = new Set([
// -----[ EU 28 ]-----
'AT', // Austria
'BE', // Belgium
Expand Down Expand Up @@ -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')
Expand Down