FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
github-docs/javascripts/user-agent.js at main · 0xdevalias/github-docs · GitHub
0xdevalias
/
github-docs
Public
forked from
github/docs
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
github-docs
/
javascripts
/
user-agent.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (28 loc) · 851 Bytes
Breadcrumbs
github-docs
/
javascripts
/
user-agent.js
Copy path
File metadata and controls
31 lines (28 loc) · 851 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// A tiny user agent checking RegExp for analytics purposes
// The order matters with these
const
OS_REGEXPS
=
[
/
(
i
p
h
o
n
e
o
s
|
i
p
a
d
o
s
)
(
[
^
)
;
]
+
)
/
i
,
/
(
m
a
c
)
o
s
x
(
[
^
)
;
]
+
)
/
i
,
/
(
w
i
n
d
o
w
s
)
(
[
^
)
;
]
+
)
/
i
,
/
(
a
n
d
r
o
i
d
)
(
[
^
)
;
]
+
)
/
i
,
/
(
l
i
n
u
x
)
(
[
^
)
;
]
+
)
/
i
]
// The order matters with these
const
BROWSER_REGEXPS
=
[
/
(
f
i
r
e
f
o
x
)
\/
(
[
^
\s
)
]
+
)
/
i
,
/
(
e
d
g
e
)
\/
(
[
^
\s
)
]
+
)
/
i
,
/
(
c
h
r
o
m
e
)
\/
(
[
^
\s
)
]
+
)
/
i
,
/
(
s
a
f
a
r
i
)
\/
(
[
^
\s
)
]
+
)
/
i
,
/
m
s
(
i
e
)
\/
(
[
^
\s
)
]
+
)
/
i
]
export
default
function
parseUserAgent
(
ua
=
navigator
.
userAgent
)
{
ua
=
ua
.
toLowerCase
(
)
let
[
,
os
=
'other'
,
os_version
=
'0'
]
=
ua
.
match
(
OS_REGEXPS
.
find
(
re
=>
re
.
test
(
ua
)
)
)
if
(
os
===
'iphone os'
||
os
===
'ipad os'
)
os
=
'ios'
const
[
,
browser
=
'other'
,
browser_version
=
'0'
]
=
ua
.
match
(
BROWSER_REGEXPS
.
find
(
re
=>
re
.
test
(
ua
)
)
)
return
{
os
,
os_version
,
browser
,
browser_version
}
}
Back
|
FazBrowse Home
|
New Git URL