Skip to content
Merged
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
16 changes: 3 additions & 13 deletions apps/site/util/detectOS.ts
Original file line number Diff line number Diff line change
@@ -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``
Expand Down
Loading