MCPcopy Index your code
hub / github.com/nodejs/nodejs.org / detectOsInUserAgent

Function detectOsInUserAgent

apps/site/util/userAgent.ts:19–24  ·  view source on GitHub ↗
(
  userAgent: string | undefined
)

Source from the content-addressed store, hash-verified

17 * @returns The detected OS or 'OTHER' if not recognized
18 */
19export const detectOsInUserAgent = (
20 userAgent: string | undefined
21): OperatingSystem => {
22 const osMatch = userAgent?.match(OS_PATTERNS);
23 return osMatch ? (osMatch[1].toUpperCase() as OperatingSystem) : 'OTHER';
24};
25
26/**
27 * Detects operating system using navigator.userAgent

Callers 2

userAgent.test.mjsFile · 0.90
detectOSFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected