MCPcopy Index your code
hub / github.com/github/docs / parseUserAgent

Function parseUserAgent

components/lib/user-agent.ts:22–30  ·  view source on GitHub ↗
(ua = navigator.userAgent)

Source from the content-addressed store, hash-verified

20]
21
22export function parseUserAgent(ua = navigator.userAgent) {
23 ua = ua.toLowerCase()
24 const osRe = OS_REGEXPS.find((re) => re.test(ua))
25 let [, os = 'other', os_version = '0'] = (osRe && ua.match(osRe)) || []
26 if (os === 'iphone os' || os === 'ipad os') os = 'ios'
27 const browserRe = BROWSER_REGEXPS.find((re) => re.test(ua))
28 const [, browser = 'other', browser_version = '0'] = (browserRe && ua.match(browserRe)) || []
29 return { os, os_version, browser, browser_version }
30}

Callers 3

sendEventFunction · 0.90
PlatformPickerFunction · 0.90
user-agent.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected