diff --git a/apps/site/util/detectOS.ts b/apps/site/util/detectOS.ts index 92b8f2277e39e..351eb1a9fe444 100644 --- a/apps/site/util/detectOS.ts +++ b/apps/site/util/detectOS.ts @@ -1,19 +1,9 @@ import type { UserOS } from '@/types/userOS'; export const detectOsInUserAgent = (userAgent: string | undefined): UserOS => { - const osMatch = userAgent?.match(/(Win|Mac|Linux)/); - switch (osMatch && osMatch[1]) { - case 'Win': - return 'WIN'; - case 'Mac': - return 'MAC'; - case 'Linux': - return 'LINUX'; - case 'AIX': - return 'AIX'; - default: - return 'OTHER'; - } + // Match OS names and convert to uppercase directly if there's a match + const osMatch = userAgent?.match(/(Win|Mac|Linux|AIX)/); + return osMatch ? (osMatch[1].toUpperCase() as UserOS) : 'OTHER'; }; // Since `navigator.appVersion` is deprecated, we use the `userAgent``