From 684863d6c7d6c9d7de247cf8119b6fcd32bb39e0 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Mon, 3 Nov 2025 16:44:01 -0800 Subject: [PATCH] Added laptop detection. Reorganized IP headers. --- src/lib/detect.ts | 14 +++++++++++--- src/lib/ip.ts | 19 ++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/lib/detect.ts b/src/lib/detect.ts index 16ff97da..c5528465 100644 --- a/src/lib/detect.ts +++ b/src/lib/detect.ts @@ -30,10 +30,18 @@ const PROVIDER_HEADERS = [ }, ]; -export function getDevice(userAgent: string) { +export function getDevice(userAgent: string, screen: string = '') { const { device } = UAParser(userAgent); - return device?.type || 'desktop'; + const [width] = screen.split('x'); + + const type = device?.type || 'desktop'; + + if (type === 'desktop' && screen && +width <= 1920) { + return 'laptop'; + } + + return type; } function getRegionCode(country: string, region: string) { @@ -108,7 +116,7 @@ export async function getClientInfo(request: Request, payload: Record