mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-15 14:42:16 +03:00
Compare commits
505 Commits
0.7.18
...
2.0.0-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9ac3566cb | ||
|
|
1d776d469b | ||
|
|
e6a085f710 | ||
|
|
37c61736c3 | ||
|
|
ac282df13e | ||
|
|
5a0d9cc3d0 | ||
|
|
f6fbf170e3 | ||
|
|
a9247154e0 | ||
|
|
f57f8fa1a7 | ||
|
|
8fea17f296 | ||
|
|
a4b4e8a2c2 | ||
|
|
954ce35755 | ||
|
|
ea4f145e64 | ||
|
|
91d2d2c0e8 | ||
|
|
b5546ee39f | ||
|
|
b3f4321bb6 | ||
|
|
aa76da90d9 | ||
|
|
817c5835ef | ||
|
|
6ea6936632 | ||
|
|
9b182526fa | ||
|
|
f17d2d7664 | ||
|
|
9652169da0 | ||
|
|
bf1d7267f6 | ||
|
|
5226361348 | ||
|
|
385e0aaee5 | ||
|
|
a661ab61d5 | ||
|
|
647e115a1e | ||
|
|
05a98aceda | ||
|
|
807dcdbded | ||
|
|
1522691426 | ||
|
|
f538018f8e | ||
|
|
3f105fe93b | ||
|
|
129657673b | ||
|
|
3dd4b60ee9 | ||
|
|
73a936001a | ||
|
|
2046b77ede | ||
|
|
d168b75a3a | ||
|
|
6e26e38247 | ||
|
|
3cb567c154 | ||
|
|
f76d8983ca | ||
|
|
22eae9f70c | ||
|
|
f2e4b242ce | ||
|
|
153831d2ed | ||
|
|
072a82b87b | ||
|
|
15d17e97a1 | ||
|
|
df9144b493 | ||
|
|
a519d2b879 | ||
|
|
102dc51683 | ||
|
|
1a806453f9 | ||
|
|
3d5c70457e | ||
|
|
a74ebeb82e | ||
|
|
4c77c5ef21 | ||
|
|
9102871dea | ||
|
|
1653d376ca | ||
|
|
29fb85658a | ||
|
|
c3be7326b8 | ||
|
|
5a26ac146e | ||
|
|
35c2b91534 | ||
|
|
feefb81cd0 | ||
|
|
0ac5028137 | ||
|
|
1b17315935 | ||
|
|
f92bb9ef65 | ||
|
|
f659659500 | ||
|
|
6c58ac39cd | ||
|
|
432a2ee72d | ||
|
|
c2f17004b8 | ||
|
|
f5af76a2b3 | ||
|
|
99baf60d50 | ||
|
|
46f38adb83 | ||
|
|
ff26813708 | ||
|
|
e62cded083 | ||
|
|
2fb0c72898 | ||
|
|
801c2409b3 | ||
|
|
a8951ec282 | ||
|
|
07c9e36ebe | ||
|
|
407b23262c | ||
|
|
16b416d9ea | ||
|
|
05747dba37 | ||
|
|
625ece73e2 | ||
|
|
e01663b48f | ||
|
|
59d8d836c2 | ||
|
|
b385a73340 | ||
|
|
4711805a1c | ||
|
|
5d2acd8fe7 | ||
|
|
359cbecd32 | ||
|
|
1e80cf3533 | ||
|
|
b09878934f | ||
|
|
30de983043 | ||
|
|
894512c72f | ||
|
|
4af26c7a5e | ||
|
|
a6c85d0148 | ||
|
|
7a4fe6f454 | ||
|
|
af65fd6960 | ||
|
|
ba28d33d51 | ||
|
|
82567c28ab | ||
|
|
e70d09a1f8 | ||
|
|
3af8e1e272 | ||
|
|
172f57ffea | ||
|
|
33f02099d1 | ||
|
|
33df5dc698 | ||
|
|
49d6422ebd | ||
|
|
a1d816ae21 | ||
|
|
0097b211db | ||
|
|
6b3fc3e0f1 | ||
|
|
08436ce4f5 | ||
|
|
df1a1c7bb4 | ||
|
|
31f94f3a51 | ||
|
|
6821276669 | ||
|
|
41f8d76968 | ||
|
|
c78346d3b4 | ||
|
|
f8dde65d54 | ||
|
|
60d3a2fbbc | ||
|
|
aff5a209f8 | ||
|
|
5672a2e15c | ||
|
|
3c3c03ceeb | ||
|
|
d99ff741f4 | ||
|
|
9ee128ae2b | ||
|
|
c6b4c867d5 | ||
|
|
f1449a8202 | ||
|
|
18730452f2 | ||
|
|
5ea9f0ec16 | ||
|
|
03b0a5afa6 | ||
|
|
d03c74d6b7 | ||
|
|
f18516c9c8 | ||
|
|
746ac28f94 | ||
|
|
96fb3a5ed5 | ||
|
|
6c34c3d4fa | ||
|
|
f8e5a1fb4f | ||
|
|
c9d1ab9561 | ||
|
|
f815ca6e9c | ||
|
|
0cbeb7a829 | ||
|
|
bf4fb916ca | ||
|
|
68447d883a | ||
|
|
0b0c7ff617 | ||
|
|
5b2e80bdfd | ||
|
|
ba0f25c19d | ||
|
|
4d3048aaaa | ||
|
|
97e4a89685 | ||
|
|
1a521b867f | ||
|
|
5d4ca2b4c2 | ||
|
|
cf093222e5 | ||
|
|
f2d0db001d | ||
|
|
a6140a17dd | ||
|
|
2033eb4aba | ||
|
|
a886604935 | ||
|
|
b814bcd791 | ||
|
|
df7551c9b6 | ||
|
|
94f2d604d1 | ||
|
|
e5942dc505 | ||
|
|
4ef9841592 | ||
|
|
528e7aea1c | ||
|
|
5e33df3b6b | ||
|
|
a8a4e71345 | ||
|
|
1f6a7e2860 | ||
|
|
db5567d614 | ||
|
|
2f7017b4d5 | ||
|
|
8ffdf232f4 | ||
|
|
98096f1454 | ||
|
|
5fd47ee00d | ||
|
|
6fde0d92d6 | ||
|
|
7f71024161 | ||
|
|
c239ac5167 | ||
|
|
8d3c2d327c | ||
|
|
d11fc47dc9 | ||
|
|
b490110109 | ||
|
|
cb5da5ea4b | ||
|
|
b2d685dd9c | ||
|
|
8d21e34201 | ||
|
|
48d930f0f1 | ||
|
|
55b5b40c7d | ||
|
|
d141915d45 | ||
|
|
8483ac09b3 | ||
|
|
896bdd04e4 | ||
|
|
25fff62540 | ||
|
|
ea04d018bb | ||
|
|
29b613deee | ||
|
|
238391a977 | ||
|
|
384f780a70 | ||
|
|
75e58525fe | ||
|
|
ebb32d1ad9 | ||
|
|
dea39e1693 | ||
|
|
ca417e25a9 | ||
|
|
f54d3fadac | ||
|
|
21fe76742f | ||
|
|
30ac448a0c | ||
|
|
1e82d7d265 | ||
|
|
a5cdc2975b | ||
|
|
180846b80a | ||
|
|
061a7a6145 | ||
|
|
ebebf0acb3 | ||
|
|
15ae12b71d | ||
|
|
4f77fbb441 | ||
|
|
cd25bc1866 | ||
|
|
534ba7dd7c | ||
|
|
0b423078c8 | ||
|
|
779b5dc1e5 | ||
|
|
18a4e5ade2 | ||
|
|
534d577355 | ||
|
|
fe963b58e5 | ||
|
|
6e39c8a553 | ||
|
|
3d4ec6ef3b | ||
|
|
f02a431000 | ||
|
|
b6bddd8c09 | ||
|
|
a29213960c | ||
|
|
f761a89ab2 | ||
|
|
7ddb2575bd | ||
|
|
23ad60ea68 | ||
|
|
97f3368ef0 | ||
|
|
b86860e850 | ||
|
|
157af1e2f2 | ||
|
|
b4cfe1b624 | ||
|
|
95fea1cb26 | ||
|
|
30648cef1d | ||
|
|
10c978eca5 | ||
|
|
fbd2c6853c | ||
|
|
29d5e43342 | ||
|
|
051aa5d284 | ||
|
|
139fbc321a | ||
|
|
191fed9127 | ||
|
|
8fe448fddf | ||
|
|
343d584f8f | ||
|
|
ef54fd35d6 | ||
|
|
79535f5d61 | ||
|
|
ee743946e8 | ||
|
|
f57bd9523d | ||
|
|
ffc03acd64 | ||
|
|
62cc99d7cf | ||
|
|
b542df155a | ||
|
|
15aa73de40 | ||
|
|
336ce2b950 | ||
|
|
20a428c351 | ||
|
|
47c310e203 | ||
|
|
825edbbf91 | ||
|
|
299283c436 | ||
|
|
39e8d4af03 | ||
|
|
03c915277a | ||
|
|
1e7b6d2e8b | ||
|
|
e5e13adc81 | ||
|
|
837042a3e8 | ||
|
|
7b3aa9fc15 | ||
|
|
8e55e00177 | ||
|
|
ca644313d6 | ||
|
|
ca83d4c9c3 | ||
|
|
9bed2b1437 | ||
|
|
3792900410 | ||
|
|
c05e4e837f | ||
|
|
c53a2a1f72 | ||
|
|
559ecaacb6 | ||
|
|
f715023f47 | ||
|
|
36b2275add | ||
|
|
75620c7b6c | ||
|
|
1d3c98a10c | ||
|
|
c39590b673 | ||
|
|
9200e53787 | ||
|
|
6c671dd246 | ||
|
|
535f11bd24 | ||
|
|
642c0399e8 | ||
|
|
3edacddb24 | ||
|
|
acc0b91ff5 | ||
|
|
f726dcd1ae | ||
|
|
383ca587ef | ||
|
|
7c8aa435b2 | ||
|
|
09aa9105dc | ||
|
|
557cc2198d | ||
|
|
f95aced43b | ||
|
|
24950f97ae | ||
|
|
cb30756f48 | ||
|
|
0868e372e0 | ||
|
|
9d431cfddd | ||
|
|
c937400e8e | ||
|
|
8bea5c552a | ||
|
|
3843578de9 | ||
|
|
be9a066029 | ||
|
|
6f2ba7fcd5 | ||
|
|
d72de26ef9 | ||
|
|
80fae81eee | ||
|
|
91fa6dd5cc | ||
|
|
a6b0c165c4 | ||
|
|
999764cf36 | ||
|
|
0e70fc4044 | ||
|
|
3b703a6379 | ||
|
|
4f27489ccf | ||
|
|
2cfd792d24 | ||
|
|
b406b5df2c | ||
|
|
536b9e8d9d | ||
|
|
8d5685771d | ||
|
|
69a568ae49 | ||
|
|
59d947dcab | ||
|
|
62cb5a2e54 | ||
|
|
cd61aef07d | ||
|
|
afe62e915d | ||
|
|
ef4eeadcd8 | ||
|
|
3da59cef3d | ||
|
|
a0b40be04f | ||
|
|
73fb12b379 | ||
|
|
94d3550844 | ||
|
|
14e7dd3f86 | ||
|
|
dff9746527 | ||
|
|
effd766e3b | ||
|
|
4d94c6b3e3 | ||
|
|
daeb118543 | ||
|
|
c47f458586 | ||
|
|
8c2b84fc31 | ||
|
|
1667f5f2b2 | ||
|
|
e1905168a8 | ||
|
|
10475761cf | ||
|
|
db381cad92 | ||
|
|
bb16473fac | ||
|
|
fe5ca1de96 | ||
|
|
ebccc29d97 | ||
|
|
1a8cd671ab | ||
|
|
d1ba5f5914 | ||
|
|
e402a6a55c | ||
|
|
e612b44ecd | ||
|
|
fc1d3b0719 | ||
|
|
c626c01a5e | ||
|
|
d1ea2f0dc4 | ||
|
|
70a586d4b1 | ||
|
|
9da55e9791 | ||
|
|
6c44b3fcc5 | ||
|
|
b1f34c1620 | ||
|
|
1cfe34f517 | ||
|
|
6c87e069ec | ||
|
|
d658ef364b | ||
|
|
f85dc8cb9a | ||
|
|
cdac86782b | ||
|
|
46615e70db | ||
|
|
6aa3ff1374 | ||
|
|
dce862364b | ||
|
|
ec5a864abb | ||
|
|
d78a2e0361 | ||
|
|
f661da9d47 | ||
|
|
9999815ac8 | ||
|
|
809439e20e | ||
|
|
5b83893476 | ||
|
|
9d154cc41b | ||
|
|
7679003f87 | ||
|
|
cd1bfd87c5 | ||
|
|
45bf76a0fe | ||
|
|
f543c5ad72 | ||
|
|
89a72c27a7 | ||
|
|
314131d003 | ||
|
|
386ebc29f1 | ||
|
|
b0f14de2a4 | ||
|
|
fd8a583020 | ||
|
|
cc2da937c6 | ||
|
|
34e2e800c5 | ||
|
|
26c74ef356 | ||
|
|
e4b3029668 | ||
|
|
b7d4865afd | ||
|
|
d5ab75a14e | ||
|
|
c7475db860 | ||
|
|
83d37b4887 | ||
|
|
2d53ceb8bf | ||
|
|
d107155a57 | ||
|
|
43fb4d16a7 | ||
|
|
6d1f26df05 | ||
|
|
86471ad7e2 | ||
|
|
9dfa5fc675 | ||
|
|
4547dbc0b4 | ||
|
|
7b23335d29 | ||
|
|
da53c35f91 | ||
|
|
edd84eaa72 | ||
|
|
1a75bc845f | ||
|
|
e72371c34d | ||
|
|
e96f95802d | ||
|
|
aa190ad319 | ||
|
|
233d3bae22 | ||
|
|
3547f16d08 | ||
|
|
da113f9fad | ||
|
|
150ad0b176 | ||
|
|
ba5324d3cd | ||
|
|
631d0501bb | ||
|
|
20ceaf9000 | ||
|
|
a8972c7d70 | ||
|
|
8196cb1c43 | ||
|
|
624eaf3f8a | ||
|
|
4ca311224f | ||
|
|
5230745280 | ||
|
|
cc11bc6a2c | ||
|
|
bd6dee4a08 | ||
|
|
1fc9d5a4a4 | ||
|
|
7568f0a6f5 | ||
|
|
726a458c84 | ||
|
|
4daaa41211 | ||
|
|
74c973b0d8 | ||
|
|
43169ce1da | ||
|
|
b0059eff5b | ||
|
|
ec0d7c037a | ||
|
|
a8eac11d82 | ||
|
|
e15ac48f0f | ||
|
|
74cb3d417b | ||
|
|
b45bd07bab | ||
|
|
feafa4d027 | ||
|
|
fc08e23f54 | ||
|
|
590234ba13 | ||
|
|
31a0460b60 | ||
|
|
e1dd27cc3f | ||
|
|
e14dcd598c | ||
|
|
d260bcca37 | ||
|
|
9da7fd4f92 | ||
|
|
5cbd2fa795 | ||
|
|
7fca67cbc7 | ||
|
|
ac123a98de | ||
|
|
65b3804625 | ||
|
|
c558a64ec5 | ||
|
|
c191372e67 | ||
|
|
5050ef75f6 | ||
|
|
3768a26e5d | ||
|
|
12a96a992a | ||
|
|
3a78cf598d | ||
|
|
8457f61f60 | ||
|
|
ca14b133cb | ||
|
|
411e41afd8 | ||
|
|
44d4ed5350 | ||
|
|
e5a02c0e57 | ||
|
|
c752520041 | ||
|
|
ee391c8888 | ||
|
|
a88934fadf | ||
|
|
8cf2a87938 | ||
|
|
b1d6eda6e1 | ||
|
|
a9fc6163b8 | ||
|
|
7ef62a68de | ||
|
|
de3b3bd55e | ||
|
|
700220f2b9 | ||
|
|
90ae87ec17 | ||
|
|
f60fdbefa5 | ||
|
|
97e919024b | ||
|
|
a88b70bdd4 | ||
|
|
0b7d05bae0 | ||
|
|
7d4d9fd476 | ||
|
|
89635fcc6e | ||
|
|
b6d2bb5262 | ||
|
|
73192e64d4 | ||
|
|
557c46f413 | ||
|
|
9fb502ea6d | ||
|
|
37cac21d0c | ||
|
|
95f37b4ce5 | ||
|
|
cc479f81ae | ||
|
|
d1a7f365ad | ||
|
|
a4da1e2b65 | ||
|
|
795139e1b8 | ||
|
|
97dc89ae03 | ||
|
|
cd3ba72b2f | ||
|
|
995e872ff8 | ||
|
|
3bad800860 | ||
|
|
bc4fd7417c | ||
|
|
6f27f8b862 | ||
|
|
df5229cb62 | ||
|
|
732cf5834e | ||
|
|
ddcc29f63f | ||
|
|
ce95d9ac17 | ||
|
|
56978dec0a | ||
|
|
60c4c2b693 | ||
|
|
213d2296df | ||
|
|
ed1ccb3902 | ||
|
|
61e5d24bb5 | ||
|
|
7c5991a725 | ||
|
|
3a5a701375 | ||
|
|
f6ef14d0cd | ||
|
|
7aca357879 | ||
|
|
7f8f357995 | ||
|
|
0fd919bd51 | ||
|
|
a400d2163c | ||
|
|
073c672af5 | ||
|
|
93e17524c0 | ||
|
|
2c7e61f9a2 | ||
|
|
87c6e5c1bd | ||
|
|
b88c52131f | ||
|
|
6c2a767e32 | ||
|
|
7dbf0c6867 | ||
|
|
0304152f72 | ||
|
|
4cc29dd88c | ||
|
|
95fcd3f672 | ||
|
|
d7608d0459 | ||
|
|
f8820389a9 | ||
|
|
46b9f0f2aa | ||
|
|
41ccecadea | ||
|
|
964431ef89 | ||
|
|
bf79eabecc | ||
|
|
01eab85f7d | ||
|
|
384bafe31c | ||
|
|
eb83122c5e | ||
|
|
64bd8a4e60 | ||
|
|
fc4c0df095 | ||
|
|
a142c0ee94 | ||
|
|
5c30aeed59 | ||
|
|
00064be6d6 | ||
|
|
76be1cb328 | ||
|
|
d601ab195f | ||
|
|
ac3b0624b8 | ||
|
|
b49865266c | ||
|
|
565d67bbb6 | ||
|
|
58c71a019e | ||
|
|
8c2607aac9 | ||
|
|
55ffb10a5f | ||
|
|
1493587742 | ||
|
|
f5e0aa83eb | ||
|
|
8fdc32f5b8 | ||
|
|
0059eef770 | ||
|
|
93affc671c | ||
|
|
a3f5efa680 | ||
|
|
4c00ccc6c2 | ||
|
|
2c28b3e97e | ||
|
|
7fbb93c99a |
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: faisalman
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: ua-parser-js
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: ['https://www.paypal.me/faisalman/']
|
||||
43
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
43
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Library version**
|
||||
Which version of the library that you use, eg: v0.7.35 or v2.0.0-alpha.3
|
||||
|
||||
For the issue related with detection result, you can use the demo section in https://uaparser.js.org to confirm
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
1
.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
vendored
Normal file
1
.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
vendored
Normal file
@@ -0,0 +1 @@
|
||||
- [ ] I have read and accept the [Contributor License Agreement (CLA)](https://gist.github.com/faisalman/2ed16621ebb544157eba85a7f7381417) Document and I hereby sign the CLA
|
||||
78
.github/workflows/analysis-codeql.yml
vendored
Normal file
78
.github/workflows/analysis-codeql.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: CodeQL Analysis
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master"]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "master" ]
|
||||
schedule:
|
||||
- cron: '15 6 * * 0'
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Use only 'java' to analyze code written in Java, Kotlin or both
|
||||
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
# - name: Autobuild
|
||||
# uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||
|
||||
# - run: |
|
||||
# echo "Run, Build Application using script"
|
||||
# ./location_of_script_within_repo/buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
20
.github/workflows/analysis-dependency.yml
vendored
Normal file
20
.github/workflows/analysis-dependency.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# Dependency Review Action
|
||||
#
|
||||
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
|
||||
#
|
||||
# Source repository: https://github.com/actions/dependency-review-action
|
||||
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
|
||||
name: Dependency Analysis
|
||||
on: [pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@v3
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@v2
|
||||
72
.github/workflows/analysis-scorecard.yml
vendored
Normal file
72
.github/workflows/analysis-scorecard.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# This workflow uses actions that are not certified by GitHub. They are provided
|
||||
# by a third-party and are governed by separate terms of service, privacy
|
||||
# policy, and support documentation.
|
||||
|
||||
name: OpenSSF's Scorecard Analysis
|
||||
on:
|
||||
# For Branch-Protection check. Only the default branch is supported. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
||||
branch_protection_rule:
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
schedule:
|
||||
- cron: '45 2 * * 4'
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
# Uncomment the permissions below if installing in a private repository.
|
||||
# contents: read
|
||||
# actions: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecard on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
||||
repo_token: ${{ secrets.SCORECARD_TOKEN }}
|
||||
|
||||
# Public repositories:
|
||||
# - Publish results to OpenSSF REST API for easy access by consumers
|
||||
# - Allows the repository to include the Scorecard badge.
|
||||
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories:
|
||||
# - `publish_results` will always be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
22
.github/workflows/publish-github-packages.yml
vendored
Normal file
22
.github/workflows/publish-github-packages.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Publish to GitHub Package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18.x'
|
||||
registry-url: https://npm.pkg.github.com/
|
||||
- run: npm ci
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
23
.github/workflows/publish-npm-packages.yml
vendored
Normal file
23
.github/workflows/publish-npm-packages.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Publish to NPM
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- run: npm install -g npm
|
||||
- run: npm ci
|
||||
- run: npm publish --provenance --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
23
.github/workflows/test-ci.yml
vendored
Normal file
23
.github/workflows/test-ci.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: UAParser.js CI-Test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
run-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64, ppc64le]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
- name: Run the test
|
||||
run: |
|
||||
npm ci
|
||||
npx playwright install
|
||||
npm test
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,5 +1,8 @@
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
playwright-report/
|
||||
test-results/
|
||||
|
||||
### vim ###
|
||||
.*.s[a-w][a-z]
|
||||
*.un~
|
||||
@@ -8,17 +11,20 @@ Session.vim
|
||||
*~
|
||||
.versions
|
||||
|
||||
### editors ###
|
||||
.vscode
|
||||
.idea
|
||||
*.sublime-*
|
||||
|
||||
### OSX ###
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.idea
|
||||
|
||||
13
.travis.yml
13
.travis.yml
@@ -1,13 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- stable
|
||||
- "0.10"
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
|
||||
sudo: false
|
||||
90
CHANGELOG.md
Normal file
90
CHANGELOG.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# UAParser.js Changelog
|
||||
|
||||
# Version 2.0
|
||||
- What's breaking:
|
||||
- Dual-licensed under AGPLv3 or PRO License
|
||||
- Browser detection on mobile device: `"Chrome" => "Mobile Chrome"`, `"Firefox" => "Mobile Firefox"`
|
||||
- OS detection: `"Mac OS" => "macOS"`, `"Chromium OS" => "Chrome OS"`
|
||||
- What's new:
|
||||
- Some new methods in result object:
|
||||
- Support for client hints: `withClientHints()`
|
||||
- Support for feature detection: `withFeatureCheck()`
|
||||
- Utility for easy comparison: `is()`
|
||||
- Utility to print full-name: `toString()`
|
||||
- Support for ES module `import { UAParser } from 'ua-parser-js'`
|
||||
- Provided Enums submodule `'ua-parser-js/enums'`
|
||||
- Provided Extensions submodule `'ua-parser-js/extensions'`
|
||||
- Provided Helpers submodule `'ua-parser-js/helpers'`
|
||||
|
||||
# Version 0.7 / 1.0
|
||||
|
||||
Version 1.0.x is basically the equivalent of version 0.7.x. See [#536](https://github.com/faisalman/ua-parser-js/issues/536) for the reason behind this confusion.
|
||||
|
||||
## Version 0.7.36 / 1.0.36
|
||||
- Add new browser: Snapchat
|
||||
- Add new devices: Infinix, Tecno
|
||||
- Improve device detection: Amazon Fire TV, Xiaomi POCO
|
||||
- Improve OS detection: iOS
|
||||
|
||||
## Version 0.7.35 / 1.0.35
|
||||
- Fix result from user-supplied user-agent being altered
|
||||
- Add new browser: Heytap, TikTok
|
||||
- Add new engine: LibWeb
|
||||
- Add new OS: SerenityOS
|
||||
- Improve browser detection: Yandex
|
||||
- Improve device detection: iPhone, Amazon Echo
|
||||
- Improve OS detection: iOS
|
||||
|
||||
## Version 0.7.34 / 1.0.34
|
||||
- Fix Sharp Mobile detected as Huawei Tablet
|
||||
- Fix IE8 bug
|
||||
- Add new devices : Kobo e-Reader, Apple Watch, and some new SmartTV devices
|
||||
- Add new OS : watchOS
|
||||
- Improve browser detection : Kakao, Naver, Brave
|
||||
- Improve device detection : Oculus, iPad
|
||||
- Improve OS detection : Chrome OS
|
||||
- Using navigator.userAgentData as fallback for device.type & os.name
|
||||
|
||||
## Version 0.7.33 / 1.0.33
|
||||
|
||||
- Add new browser : Cobalt
|
||||
- Identify Macintosh as an Apple device
|
||||
- Fix ReDoS vulnerability
|
||||
|
||||
## Version 0.7.32 / 1.0.32
|
||||
|
||||
- Add new browser : DuckDuckGo, Huawei Browser, LinkedIn
|
||||
- Add new OS : HarmonyOS
|
||||
- Add some Huawei models
|
||||
- Add Sharp Aquos TV
|
||||
- Improve detection Xiaomi Mi CC9
|
||||
- Fix Sony Xperia 1 III misidentified as Acer tablet
|
||||
- Fix Detect Sony BRAVIA as SmartTV
|
||||
- Fix Detect Xiaomi Mi TV as SmartTV
|
||||
- Fix Detect Galaxy Tab S8 as tablet
|
||||
- Fix WeGame mistakenly identified as WeChat
|
||||
- Fix included commas in Safari / Mobile Safari version
|
||||
- Increase UA_MAX_LENGTH to 350
|
||||
|
||||
## Version 0.7.31 / 1.0.2
|
||||
|
||||
- Fix OPPO Reno A5 incorrect detection
|
||||
- Fix TypeError Bug
|
||||
- Use AST to extract regexes and verify them with safe-regex
|
||||
|
||||
## Version 0.7.30 / 1.0.1
|
||||
|
||||
- Add new browser : Obigo, UP.Browser, Klar
|
||||
- Add new device : Oculus, Roku
|
||||
- Add new OS: Maemo, HP-UX, Android-x86, Deepin, elementary OS, GhostBSD, Linspire, Manjaro, Sabayon
|
||||
- Improve detection for Sony Xperia 1ii, LG Android TV, and some more devices
|
||||
- Improve detection for ARM64 CPU
|
||||
- Improve detection for Windows Mobile, Netscape, Mac on PowerPC
|
||||
- Categorize PDA as mobile
|
||||
- Fix Sharp devices misjudged as Huawei
|
||||
- Fix trailing comma for ES3 compatibility
|
||||
- Some code refactor
|
||||
|
||||
# Version 0.8
|
||||
|
||||
Version 0.8 was created by accident. This version is now deprecated and no longer maintained, please update to version 0.7 / 1.0.
|
||||
29
CODE_OF_CONDUCT.md
Normal file
29
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# UAParser.js Code of Conduct
|
||||
|
||||
## Introduction
|
||||
|
||||
Welcome to the UAParser.js community! We're here to collaborate on developing an awesome project. Here are some general guidelines to make our community a great place:
|
||||
|
||||
### 1. Be Kind, Honest, and Respectful
|
||||
|
||||
Always treat others with kindness and respect. We value different opinions and encourage positive communication.
|
||||
|
||||
### 2. Keep Conversations Civil and On-Topic
|
||||
|
||||
Please keep discussions related to the project. If you want to talk about something else, find the right place for it.
|
||||
|
||||
### 3. Mutual Assistance, Appreciation, and Acknowledgement
|
||||
|
||||
Feel free to ask for help, show gratitude for contributions, and make sure to give credit where it's due.
|
||||
|
||||
### 4. Resolving Disagreements
|
||||
|
||||
In the event of a disagreement, we encourage open and respectful dialogue. It's important to remember that it's okay to have differing opinions, and if a common ground can't be reached, we suggest using the 'agree to disagree' approach.
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
If you see any behavior that goes against this code of conduct, report it to [f@faisalman.com](mailto:f@faisalman.com).
|
||||
|
||||
## Conclusion
|
||||
|
||||
Together, we can make this project awesome!
|
||||
7
CONTRIBUTING.md
Normal file
7
CONTRIBUTING.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# UAParser.js: How to Contribute
|
||||
|
||||
* Fork and clone this repository
|
||||
* Make some changes as required
|
||||
* Write unit test to showcase its functionality under `/test`
|
||||
* Run the test suites to make sure it's not breaking anything `$ npm run build+test`
|
||||
* Submit a pull request under `develop` branch & check the CLA in the submission form
|
||||
71
LICENSE.md
Normal file
71
LICENSE.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# UAPARSER.JS PRO ENTERPRISE LICENSE
|
||||
|
||||
Version 1, October 2023
|
||||
|
||||
Copyright (C) 2023 Faisal Salman <f+ua-parser-js@faisalman.com>
|
||||
|
||||
---
|
||||
|
||||
## Definitions
|
||||
|
||||
"We" are the team behind UAParser.js.
|
||||
|
||||
"You" are the individual/organization/company who is responsible for purchasing this license.
|
||||
|
||||
"The Code" is UAParser.js.
|
||||
|
||||
"Project" is what you built with The Code.
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
We retains all title, intellectual property, and ownership rights to The Code.
|
||||
|
||||
The Code is licensed, not sold, to You for use solely subject to the terms and conditions detailed here.
|
||||
|
||||
We grant You (and only You) a limited, non-exclusive, non-transferable, non-sublicensable, royalty-free right to use, copy, and modify The Code.
|
||||
|
||||
This license is only valid for You as 1 (one) individual/organization/company and can not be transferred to other individual/organization/company.
|
||||
|
||||
---
|
||||
|
||||
## Rights
|
||||
|
||||
You may use, copy, and modify The Code for an indefinite number of Projects.
|
||||
|
||||
You have the right to get lifetime updates and a 1 (one) year support, starting from the time you make the purchase.
|
||||
|
||||
---
|
||||
|
||||
## Restriction
|
||||
|
||||
You may not redistribute The Code, as-is or modified, except as a part of a Project that you made.
|
||||
|
||||
If You transfer a Project to a client, the use of The Code must be limited to the original functionality that You created for them. The Code must not be extracted, reproduced, or used in any other way. You must inform your client of this condition.
|
||||
|
||||
You may not deliver a Project that contains The Code as an open-source Project that might be used for commercial purpose to the general public, except with our written consent.
|
||||
|
||||
You may not use The Code for unlawful, inappropriate, illegal, or offensive purposes.
|
||||
|
||||
---
|
||||
|
||||
## Limitations
|
||||
|
||||
The Code is provided 'as is' without warranty of any kind, expressed, or implied.
|
||||
|
||||
We shall not be liable for any damages, including but not limited to, direct, indirect, special, incidental, or consequential damages or losses that occur by the use of The Code.
|
||||
|
||||
We reserve the rights to discontinue the lifetime updates for The Code at any time, with or without notice.
|
||||
|
||||
We offer support only for question within the scope of The Code functionality or related at our sole discretion.
|
||||
|
||||
---
|
||||
|
||||
## Terminations
|
||||
|
||||
This license works indefinitely but can be revoked at any time if there is a violation to any of the terms.
|
||||
|
||||
---
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
23
README.md
Normal file
23
README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
<p align="center">
|
||||
<a href="https://uaparser.js.org"><img src="https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/uap-header.png"></a>
|
||||
</p>
|
||||
|
||||
# UAParser.js
|
||||
|
||||
Thank you for purchasing UAParser.js PRO Enterprise License, if you haven't please order here: https://store.faisalman.com
|
||||
|
||||
# Download
|
||||
|
||||
```sh
|
||||
npm install @ua-parser-js/pro-enterprise
|
||||
```
|
||||
|
||||
# Documentation
|
||||
|
||||
https://docs.uaparser.js.org/v2
|
||||
|
||||
# License
|
||||
|
||||
UAParser.js PRO Enterprise
|
||||
|
||||
Copyright (c) 2012-2023 Faisal Salman <<f@faisalman.com>>
|
||||
7
SECURITY.md
Normal file
7
SECURITY.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
To report a security issue, please email `f@faisalman.com` with a description of the issue, reproducible steps to get the issue, affected versions, and, if known, mitigations for the issue.
|
||||
|
||||
If the issue is confirmed as a vulnerability, we will open a new security advisory draft in our GitHub's Security Advisory page [https://github.com/faisalman/ua-parser-js/security/advisories](https://github.com/faisalman/ua-parser-js/security/advisories) and acknowledge your contributions as part of it. This project follows a 90 days disclosure timeline.
|
||||
17
bower.json
17
bower.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.18",
|
||||
"authors": [
|
||||
"Faisal Salman <fyzlman@gmail.com>"
|
||||
],
|
||||
"private": false,
|
||||
"main": "src/ua-parser.js",
|
||||
"ignore": [
|
||||
"build",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
13
dist/ua-parser.min.js
vendored
13
dist/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
13
dist/ua-parser.pack.js
vendored
13
dist/ua-parser.pack.js
vendored
File diff suppressed because one or more lines are too long
5032
package-lock.json
generated
Normal file
5032
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
Package.describe({
|
||||
name: 'faisalman:ua-parser-js',
|
||||
version: '0.7.18',
|
||||
version: '2.0.0-beta.1',
|
||||
summary: 'Lightweight JavaScript-based user-agent string parser',
|
||||
git: 'https://github.com/faisalman/ua-parser-js.git',
|
||||
documentation: 'readme.md'
|
||||
|
||||
177
package.json
177
package.json
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"title": "UAParser.js",
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.18",
|
||||
"title": "UAParser.js PRO Enterprise",
|
||||
"name": "@ua-parser-js/pro-enterprise",
|
||||
"version": "2.0.0-beta.1",
|
||||
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
|
||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||
"description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent & Client Hints data. Supports browser & node.js environment",
|
||||
"keywords": [
|
||||
"user-agent",
|
||||
"client-hints",
|
||||
"parser",
|
||||
"browser",
|
||||
"engine",
|
||||
@@ -13,126 +14,234 @@
|
||||
"device",
|
||||
"cpu",
|
||||
"jquery-plugin",
|
||||
"ecosystem:jquery"
|
||||
"ecosystem:jquery",
|
||||
"ua-parser-js",
|
||||
"browser-detection",
|
||||
"device-detection",
|
||||
"os-detection"
|
||||
],
|
||||
"homepage": "http://github.com/faisalman/ua-parser-js",
|
||||
"homepage": "https://github.com/faisalman/ua-parser-js",
|
||||
"contributors": [
|
||||
"Aamir Poonawalla <aamir@urx.com>",
|
||||
"Admas <mollases@users.noreply.github.com>",
|
||||
"algenon <m@antonz.ru>",
|
||||
"Alvin Portillo <alvin@8thwall.com>",
|
||||
"Amumu <yoyo837@hotmail.com>",
|
||||
"Andrea Vaghi <andrea.vaghi@jobrapido.com>",
|
||||
"Anton Zhiyanov <m@antonz.ru>",
|
||||
"Arturo Mejia <amejia@blim.com>",
|
||||
"Arun Rama Reddy <arunramareddy@gmail.com>",
|
||||
"Austin Pray <austin@austinpray.com>",
|
||||
"Bendeguz <symunona@gmail.com>",
|
||||
"Benjamin Bertrand <bertrand.design@gmail.com>",
|
||||
"Benjamin Urban <benjamin.urban@sueddeutsche.de>",
|
||||
"boneyao <admin@boneyao.com>",
|
||||
"Carl C Von Lewin <carlchristianlewin@gmail.com>",
|
||||
"CESAR RAMOS <c@imagenproactiva.com>",
|
||||
"Chad Killingsworth <ckillingsworth@jackhenry.com>",
|
||||
"chenhui9279 <chenhui9279@autohome.com.cn>",
|
||||
"chenyuan-new <53860479+chenyuan-new@users.noreply.github.com>",
|
||||
"Christopher De Cairos <chris.decairos@gmail.com>",
|
||||
"Cyrille David <cyrille@qonto.eu>",
|
||||
"Dante <duanjl.china@gmail.com>",
|
||||
"Dario Vladovic <d.vladimyr@gmail.com>",
|
||||
"David Annez <david.annez@gmail.com>",
|
||||
"Davit Barbakadze <jayarjo@gmail.com>",
|
||||
"ddivernois <david-emmanuel.divernois@amadeus.com>",
|
||||
"Deliaz <D3liaz@gmail.com>",
|
||||
"Demis Palma <demis.palma@gmail.com>",
|
||||
"dhoko <aurelien@protonmail.com>",
|
||||
"dianhe <dianhe@webank.com>",
|
||||
"dineshks1 <dineshks1@d.kumar44@outlook.com>",
|
||||
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
||||
"Douglas Li <doug@knotch.it>",
|
||||
"Dumitru Uzun <contact@duzun.me>",
|
||||
"Dustin <duburns@fanatics.com>",
|
||||
"Elchin Valiyev <elchin.valiyev@autodesk.com>",
|
||||
"Emil Hesslow <hesslow@gmail.com>",
|
||||
"Eric Redon <eric.redon@coox.org>",
|
||||
"Eric Schrenker <eric.schrenker@gmail.com>",
|
||||
"Erik Hesselink <hesselink@gmail.com>",
|
||||
"Fabian Becker <halfdan@xnorfz.de>",
|
||||
"Faisal Salman <fyzlman@gmail.com>",
|
||||
"Faisal Salman <f@faisalman.com>",
|
||||
"Frédéric Camblor <fcamblor@gmail.com>",
|
||||
"Frederik Ring <frederik.ring@gmail.com>",
|
||||
"Garrit Franke <garrit@slashdev.space>",
|
||||
"Gerald Host <me@jacobford.co.uk>",
|
||||
"Germán M. Bravo <german.mb@gmail.com>",
|
||||
"Grigory Dmitrenko <grigory@snsk.ru>",
|
||||
"gulpin <gulping.gulpin@gmail.com>",
|
||||
"Hans Ott <hansott@hotmail.be>",
|
||||
"Hendrik Helwich <h.helwich@iplabs.de>",
|
||||
"Hermann Ebert <ebbmo@HE.local>",
|
||||
"hr6r <hedian@gmail.com>",
|
||||
"Igor Topal <i.topal@smartweb.com.ua>",
|
||||
"Ildar Kamalov <i.kamalov@adguard.com>",
|
||||
"insanehong <insane.hong@navercorp.com>",
|
||||
"jackpoll <jackpoll123456@gmail.com>",
|
||||
"Jacky Choo <jackychoo@adly-macbook.local>",
|
||||
"Jake Mc <startswithaj@users.noreply.github.com>",
|
||||
"JBYoshi <12983479+JBYoshi@users.noreply.github.com>",
|
||||
"Joey Parrish <joeyparrish@google.com>",
|
||||
"John Tantalo <john.tantalo@gmail.com>",
|
||||
"John Yanarella <jmy@codecatalyst.com>",
|
||||
"Jon Buckley <jon@jbuckley.ca>",
|
||||
"Josh Goldberg <joshuakgoldberg@outlook.com>",
|
||||
"Junki-Ishida <junki_ishida@dwango.co.jp>",
|
||||
"Kendall Buchanan <kendall@kendagriff.com>",
|
||||
"KnifeLemon <role___play@naver.com>",
|
||||
"kNoAPP <alldoneb@gmail.com>",
|
||||
"Lee Treveil <leetreveil@gmail.com>",
|
||||
"leonardo <leofiore@libero.it>",
|
||||
"Levente Balogh <balogh.levente.hu@gmail.com>",
|
||||
"Liam Quinn <lquinn@blackberry.com>",
|
||||
"Lithin <lithin@webklipper.com>",
|
||||
"liujunlve <liujunlve@henhaoji.com>",
|
||||
"ll-syber <670159357@qq.com>",
|
||||
"Loris Guignard <loris.guignard@gmail.com>",
|
||||
"Lukas Drgon <lukas.drgon@gmail.com>",
|
||||
"Lukas Eipert <leipert@users.noreply.github.com>",
|
||||
"Malash <i@malash.me>",
|
||||
"Martynas <martynas@firmfirm.co>",
|
||||
"Masahiko Sato <masasato@yahoo-corp.jp>",
|
||||
"Matt Brophy <matt@brophy.org>",
|
||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
||||
"Matthew Origer <karatecowboy@gmail.com>",
|
||||
"Maximilian Haupt <mail@maximilianhaupt.com>",
|
||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
||||
"Max Nordlund <max.nordlund@gmail.com>",
|
||||
"Michael Hess <mhess@connectify.me>",
|
||||
"MimyyK <michele.marais@hakisa.com>",
|
||||
"Mok <mok@moekm.com>",
|
||||
"nabetama <mao.nabeta@gmail.com>",
|
||||
"naoh <naoh.cs03g@nctu.edu.tw>",
|
||||
"Nicholas Ionata <nionata@ufl.edu>",
|
||||
"Nikhil Motiani <nikhil.motiani@outlook.com>",
|
||||
"Nik Rolls <nik@rolls.cc>",
|
||||
"Nikhil Motiani <nikhil.m@247-inc.com>",
|
||||
"nionata <n.ionata129@gmail.com>",
|
||||
"niris <nirisix@gmail.com>",
|
||||
"Nobuo Okada <nookada@yahoo-corp.jp>",
|
||||
"o.drapeza <o.drapeza@tinkoff.ru>",
|
||||
"Oscar Becerra <oscarbecerra@google.com>",
|
||||
"otakuSiD <otakusid@gmail.com>",
|
||||
"Paris Morgan <paris@8thwall.com>",
|
||||
"patrick-nurt <github@pereira.dk>",
|
||||
"Pavel Studeny <studeny@avast.com>",
|
||||
"Peter Dave Hello <PeterDaveHello@users.noreply.github.com>",
|
||||
"philippsimon <github@philippsimon.de>",
|
||||
"Pieter Hendrickx <pieter.hendrickx@belfius.be>",
|
||||
"Piper Chester <piperchester@gmail.com>",
|
||||
"Queen Vinyl Darkscratch <vinyldarkscratch@gmail.com>",
|
||||
"Raine Makelainen <raine.makelainen@jolla.com>",
|
||||
"Raman Savaryn <homeneartheocean@gmail.com>",
|
||||
"Riley Shaw <rileyjshaw@users.noreply.github.com>",
|
||||
"Robert Tod <robert@qubit.com>",
|
||||
"roman.savarin <roman.savarin@skywindgroup.com>",
|
||||
"Ron Korland <ron@testim.io>",
|
||||
"Ross Noble <rosshnoble@gmail.com>",
|
||||
"ruicong <466403866@qq.com>",
|
||||
"Runar Heggset <rukki093@gmail.com>",
|
||||
"Ryohei Shima <shima01dev@gmail.com>",
|
||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>",
|
||||
"sgautrea <shanegautreau@gmail.com>",
|
||||
"shaharmor <shahar@peer5.com>",
|
||||
"Shane Gautreau <sgautrea@opentext.com>",
|
||||
"Shane Thacker <shane@steadymade.com>",
|
||||
"Shreedhar <shreedhar@uber.com>",
|
||||
"Simon Eisenmann <simon@longsleep.org>",
|
||||
"Simon Lang <me@simonlang.org>",
|
||||
"Stiekel <histkc@gmail.com>",
|
||||
"sunny-mwx <30586210+sunny-mwx@users.noreply.github.com>",
|
||||
"sUP <dani3l@gmail.com>",
|
||||
"Sylvain Gizard <sylvain.gizard@gmail.com>",
|
||||
"szchenghuang <szchenghuang@gmail.com>",
|
||||
"Tanguy Krotoff <tkrotoff@gmail.com>",
|
||||
"Tony Tomarchio <tony@tomarchio.cc>",
|
||||
"Ulrich Schmidt <u.schmidt@velian.de>",
|
||||
"Vadim Kurachevsky <vadim@hmvs.org>",
|
||||
"Yun Young-jin <yupmin@yupmin-office-macmini.local>"
|
||||
"Varun Sharma <varunsh@stepsecurity.io>",
|
||||
"XhmikosR <xhmikosr@gmail.com>",
|
||||
"Yılmaz <yilmazdemir36@gmail.com>",
|
||||
"yuanyang <work_yuanyang@163.com>",
|
||||
"Yun Young-jin <yupmin@yupmin-office-macmini.local>",
|
||||
"Zach Bjornson <zbbjornson@gmail.com>",
|
||||
"Ziding Zhang <zidingz@gmail.com>"
|
||||
],
|
||||
"main": "src/ua-parser.js",
|
||||
"scripts": {
|
||||
"build": "uglifyjs src/ua-parser.js -o dist/ua-parser.min.js --comments '/UAParser\\.js/' && uglifyjs src/ua-parser.js -o dist/ua-parser.pack.js --comments '/UAParser\\.js/' --compress --mangle",
|
||||
"test": "jshint src/ua-parser.js && mocha -R nyan test/test.js",
|
||||
"verup": "node ./node_modules/verup",
|
||||
"version": "node ./node_modules/verup 0"
|
||||
"type": "commonjs",
|
||||
"types": "src/main/ua-parser.d.ts",
|
||||
"main": "src/main/ua-parser.js",
|
||||
"module": "src/main/ua-parser.mjs",
|
||||
"browser": "dist/ua-parser.pack.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./src/main/ua-parser.js",
|
||||
"import": "./src/main/ua-parser.mjs"
|
||||
},
|
||||
"./enums": {
|
||||
"require": "./src/enums/ua-parser-enums.js",
|
||||
"import": "./src/enums/ua-parser-enums.mjs"
|
||||
},
|
||||
"./extensions": {
|
||||
"require": "./src/extensions/ua-parser-extensions.js",
|
||||
"import": "./src/extensions/ua-parser-extensions.mjs"
|
||||
}
|
||||
},
|
||||
"verup": {
|
||||
"files": [
|
||||
"bower.json",
|
||||
"package.js",
|
||||
"src/ua-parser.js"
|
||||
],
|
||||
"regs": [
|
||||
"^((?:\\$|(\\s*\\*\\s*@)|(\\s*(?:var|,)?\\s+))(?:LIBVERSION|version)[\\s\\:='\"]+)([0-9]+(?:\\.[0-9]+){2,2})",
|
||||
"^(\\s?\\*.*v)([0-9]+(?:\\.[0-9]+){2,2})"
|
||||
]
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "./script/build-dist.sh && ./script/build-module.js",
|
||||
"build+test": "npm run build && npm run test",
|
||||
"fuzz": "jazzer ./test/jazzer-fuzz-test.js --sync",
|
||||
"test": "./script/test-all.sh",
|
||||
"test:dts": "tsd --typings src/main/ua-parser.d.ts --files test/dts-test.ts",
|
||||
"test:eslint": "eslint src && eslint script",
|
||||
"test:jshint": "jshint src/main",
|
||||
"test:lockfile-lint": "npx lockfile-lint -p package-lock.json",
|
||||
"test:mocha": "mocha -R list test/mocha*js",
|
||||
"test:playwright": "playwright test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jshint": "~1.1.0",
|
||||
"mocha": "~1.8.0",
|
||||
"requirejs": "^2.3.2",
|
||||
"uglify-js": "~2.7.5",
|
||||
"verup": "^1.3.x"
|
||||
"@babel/parser": "7.15.8",
|
||||
"@babel/traverse": "7.15.4",
|
||||
"@jazzer.js/core": "^1.4.0",
|
||||
"@playwright/test": "~1.32.2",
|
||||
"jshint": "~2.13.6",
|
||||
"mocha": "~8.2.0",
|
||||
"requirejs": "2.3.2",
|
||||
"safe-regex": "^2.1.1",
|
||||
"tsd": "^0.29.0",
|
||||
"uglify-js": "~3.12.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||
},
|
||||
"license": "(GPL-2.0 OR MIT)",
|
||||
"license": "UAParser.js-PRO-Enterprise",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"directories": {
|
||||
"dist": "dist",
|
||||
"script": "script",
|
||||
"src": "src",
|
||||
"test": "test"
|
||||
},
|
||||
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
||||
"demo": "https://faisalman.github.io/ua-parser-js",
|
||||
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.min.js"
|
||||
"demo": "https://uaparser.js.org",
|
||||
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.pack.js",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/ua-parser-js"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/faisalman"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/faisalman"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
330
readme.md
330
readme.md
@@ -1,330 +0,0 @@
|
||||
# UAParser.js
|
||||
|
||||
<img align="right" src="https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/logo.png"> A JavaScript-based User-Agent string parser. Can be used either in browser (client-side) or in node.js (server-side) environment. Also available as jQuery/Zepto plugin, Bower/Meteor package, & RequireJS/AMD module. This library aims to identify detailed type of web browser, layout engine, operating system, cpu architecture, and device type/model, entirely from user-agent string with a relatively small footprint (~11KB when minified / ~4KB gzipped). Written in vanilla JavaScript, which means it doesn't require any other library and can be used independently. However, it's not recommended to use this library as browser detection since the result may not be more accurate than using feature detection.
|
||||
|
||||
[](https://travis-ci.org/faisalman/ua-parser-js)
|
||||
[](https://www.npmjs.com/package/ua-parser-js)
|
||||
[](https://www.npmjs.com/package/ua-parser-js)
|
||||
[](https://bower.io/)
|
||||
[](https://cdnjs.com/libraries/UAParser.js)
|
||||
[](https://gratipay.com/UAParser.js)
|
||||
[](http://flattr.com/thing/3867907/faisalmanua-parser-js-on-GitHub)
|
||||
|
||||
* Author : Faisal Salman <<f@faisalman.com>>
|
||||
* Demo : http://faisalman.github.io/ua-parser-js
|
||||
* Source : https://github.com/faisalman/ua-parser-js
|
||||
|
||||
# Constructor
|
||||
|
||||
* `new UAParser([uastring][,extensions])`
|
||||
* returns new instance
|
||||
|
||||
* `UAParser([uastring][,extensions])`
|
||||
* returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
||||
|
||||
# Methods
|
||||
|
||||
* `getBrowser()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```
|
||||
# Possible 'browser.name':
|
||||
Amaya, Android Browser, Arora, Avant, Baidu, Blazer, Bolt, Bowser, Camino, Chimera,
|
||||
Chrome [WebView], Chromium, Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Edge,
|
||||
Epiphany, Fennec, Firebird, Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe,
|
||||
IceCat, IceDragon, Iceweasel, IE[Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle,
|
||||
Links, Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, MIUI Browser, [Mobile] Safari,
|
||||
Mosaic, Mozilla, Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet],
|
||||
PhantomJS, Phoenix, Polaris, QQBrowser, QQBrowserLite, Quark, RockMelt, Silk, Skyfire,
|
||||
SeaMonkey, Sleipnir, SlimBrowser, Swiftfox, Tizen, UCBrowser, Vivaldi, w3m, Waterfox,
|
||||
WeChat, Yandex
|
||||
|
||||
# 'browser.version' determined dynamically
|
||||
```
|
||||
|
||||
* `getDevice()`
|
||||
* returns `{ model: '', type: '', vendor: '' }`
|
||||
|
||||
```
|
||||
# Possible 'device.type':
|
||||
console, mobile, tablet, smarttv, wearable, embedded
|
||||
|
||||
# Possible 'device.vendor':
|
||||
Acer, Alcatel, Amazon, Apple, Archos, Asus, BenQ, BlackBerry, Dell, GeeksPhone,
|
||||
Google, HP, HTC, Huawei, Jolla, Lenovo, LG, Meizu, Microsoft, Motorola, Nexian,
|
||||
Nintendo, Nokia, Nvidia, OnePlus, Ouya, Palm, Panasonic, Pebble, Polytron, RIM,
|
||||
Samsung, Sharp, Siemens, Sony[Ericsson], Sprint, Xbox, Xiaomi, ZTE
|
||||
|
||||
# 'device.model' determined dynamically
|
||||
```
|
||||
|
||||
* `getEngine()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```
|
||||
# Possible 'engine.name'
|
||||
Amaya, EdgeHTML, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto,
|
||||
Tasman, Trident, w3m, WebKit
|
||||
|
||||
# 'engine.version' determined dynamically
|
||||
```
|
||||
|
||||
* `getOS()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```
|
||||
# Possible 'os.name'
|
||||
AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS, Contiki,
|
||||
Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Gentoo, GNU, Haiku, Hurd, iOS,
|
||||
Joli, Linpus, Linux, Mac OS, Mageia, Mandriva, MeeGo, Minix, Mint, Morph OS, NetBSD,
|
||||
Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PC-BSD, PCLinuxOS, Plan9, Playstation, QNX, RedHat,
|
||||
RIM Tablet OS, RISC OS, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen,
|
||||
Ubuntu, UNIX, VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk
|
||||
|
||||
# 'os.version' determined dynamically
|
||||
```
|
||||
|
||||
* `getCPU()`
|
||||
* returns `{ architecture: '' }`
|
||||
|
||||
```
|
||||
# Possible 'cpu.architecture'
|
||||
68k, amd64, arm[64], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, sparc[64]
|
||||
```
|
||||
|
||||
* `getResult()`
|
||||
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
||||
|
||||
* `getUA()`
|
||||
* returns UA string of current instance
|
||||
|
||||
* `setUA(uastring)`
|
||||
* set UA string to parse
|
||||
* returns current instance
|
||||
|
||||
|
||||
# Example
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="ua-parser.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var parser = new UAParser();
|
||||
|
||||
// by default it takes ua string from current browser's window.navigator.userAgent
|
||||
console.log(parser.getResult());
|
||||
/*
|
||||
/// this will print an object structured like this:
|
||||
{
|
||||
ua: "",
|
||||
browser: {
|
||||
name: "",
|
||||
version: ""
|
||||
},
|
||||
engine: {
|
||||
name: "",
|
||||
version: ""
|
||||
},
|
||||
os: {
|
||||
name: "",
|
||||
version: ""
|
||||
},
|
||||
device: {
|
||||
model: "",
|
||||
type: "",
|
||||
vendor: ""
|
||||
},
|
||||
cpu: {
|
||||
architecture: ""
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// let's test a custom user-agent string as an example
|
||||
var uastring = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2";
|
||||
parser.setUA(uastring);
|
||||
|
||||
var result = parser.getResult();
|
||||
// this will also produce the same result (without instantiation):
|
||||
// var result = UAParser(uastring);
|
||||
|
||||
console.log(result.browser); // {name: "Chromium", version: "15.0.874.106"}
|
||||
console.log(result.device); // {model: undefined, type: undefined, vendor: undefined}
|
||||
console.log(result.os); // {name: "Ubuntu", version: "11.10"}
|
||||
console.log(result.os.version); // "11.10"
|
||||
console.log(result.engine.name); // "WebKit"
|
||||
console.log(result.cpu.architecture); // "amd64"
|
||||
|
||||
// do some other tests
|
||||
var uastring2 = "Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)";
|
||||
console.log(parser.setUA(uastring2).getBrowser().name); // "Konqueror"
|
||||
console.log(parser.getOS()); // {name: "OpenBSD", version: undefined}
|
||||
console.log(parser.getEngine()); // {name: "KHTML", version: "4.1.4"}
|
||||
|
||||
var uastring3 = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11';
|
||||
console.log(parser.setUA(uastring3).getDevice().model); // "PlayBook"
|
||||
console.log(parser.getOS()) // {name: "RIM Tablet OS", version: "1.0.0"}
|
||||
console.log(parser.getBrowser().name); // "Safari"
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Using node.js
|
||||
|
||||
```sh
|
||||
$ npm install ua-parser-js
|
||||
```
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var parser = require('ua-parser-js');
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
// get user-agent header
|
||||
var ua = parser(req.headers['user-agent']);
|
||||
// write the result as response
|
||||
res.end(JSON.stringify(ua, null, ' '));
|
||||
})
|
||||
.listen(1337, '127.0.0.1');
|
||||
|
||||
console.log('Server running at http://127.0.0.1:1337/');
|
||||
```
|
||||
|
||||
## Using requirejs
|
||||
|
||||
```js
|
||||
requirejs.config({
|
||||
baseUrl : 'js/lib', // path to your script directory
|
||||
paths : {
|
||||
'ua-parser-js' : 'ua-parser.min'
|
||||
}
|
||||
});
|
||||
|
||||
requirejs(['ua-parser-js'], function(UAParser) {
|
||||
var parser = new UAParser();
|
||||
console.log(parser.getResult());
|
||||
});
|
||||
```
|
||||
|
||||
## Using CDN
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/ua-parser-js@0/dist/ua-parser.min.js"></script>
|
||||
```
|
||||
|
||||
## Using bower
|
||||
|
||||
```sh
|
||||
$ bower install ua-parser-js
|
||||
```
|
||||
|
||||
## Using meteor
|
||||
|
||||
```sh
|
||||
$ meteor add faisalman:ua-parser-js
|
||||
```
|
||||
|
||||
## Using CLI
|
||||
|
||||
```sh
|
||||
$ node ua-parser.min.js "Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)"
|
||||
# multiple args
|
||||
$ node ua-parser.min.js "Opera/1.2" "Opera/3.4"
|
||||
# piped args
|
||||
$ echo "Opera/1.2" | node ua-parser.min.js
|
||||
# log file
|
||||
$ cat ua.log | node ua-parser.min.js
|
||||
```
|
||||
|
||||
## Using jQuery/Zepto ($.ua)
|
||||
|
||||
Although written in vanilla js (which means it doesn't depends on jQuery), this library will automatically detect if jQuery/Zepto is present and create `$.ua` object based on browser's user-agent (although in case you need, `window.UAParser` constructor is still present). To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
|
||||
|
||||
```js
|
||||
// In browser with default user-agent: 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0':
|
||||
|
||||
// Do some tests
|
||||
console.log($.ua.device); // {vendor: "HTC", model: "Evo Shift 4G", type: "mobile"}
|
||||
console.log($.ua.os); // {name: "Android", version: "2.3.4"}
|
||||
console.log($.ua.os.name); // "Android"
|
||||
console.log($.ua.get()); // "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0"
|
||||
|
||||
// reset to custom user-agent
|
||||
$.ua.set('Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; Xoom Build/HWI69) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13');
|
||||
|
||||
// Test again
|
||||
console.log($.ua.browser.name); // "Safari"
|
||||
console.log($.ua.engine.name); // "Webkit"
|
||||
console.log($.ua.device); // {vendor: "Motorola", model: "Xoom", type: "tablet"}
|
||||
console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
|
||||
|
||||
// Add class to <body> tag
|
||||
// <body class="ua-browser-safari ua-devicetype-tablet">
|
||||
$('body').addClass('ua-browser-' + $.ua.browser.name + ' ua-devicetype-' + $.ua.device.type);
|
||||
```
|
||||
|
||||
## Extending regex patterns
|
||||
|
||||
* `UAParser([uastring,] extensions)`
|
||||
|
||||
Pass your own regexes to extend the limited matching rules.
|
||||
|
||||
```js
|
||||
// Example:
|
||||
var myOwnRegex = [[/(myownbrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]];
|
||||
var myParser = new UAParser({ browser: myOwnRegex });
|
||||
var uaString = 'Mozilla/5.0 MyOwnBrowser/1.3';
|
||||
console.log(myParser.setUA(uaString).getBrowser()); // {name: "MyOwnBrowser", version: "1.3"}
|
||||
```
|
||||
|
||||
|
||||
# Development
|
||||
|
||||
## Contribute
|
||||
|
||||
* Fork and clone this repository
|
||||
* Make some changes as required
|
||||
* Write a unit test to showcase your feature
|
||||
* Run the test suites to make sure the changes you made didn't break anything `$ npm run test`
|
||||
* Commit and push to your own repository
|
||||
* Submit a pull request to this repository under `develop` branch
|
||||
* Profit? $$$
|
||||
|
||||
## Build
|
||||
|
||||
Build a minified & packed script
|
||||
|
||||
```sh
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
|
||||
# Donate
|
||||
|
||||
Do you use & like UAParser.js but you don’t find a way to show some love? If yes, please consider donating to support this project. Otherwise, no worries, regardless of whether there is support or not, I will keep maintaining this project. Still, if you buy me a cup of coffee I would be more than happy though :)
|
||||
|
||||
[](https://pledgie.com/campaigns/34252)
|
||||
|
||||
|
||||
# License
|
||||
|
||||
Dual licensed under GPLv2 or MIT
|
||||
|
||||
Copyright © 2012-2016 Faisal Salman <<fyzlman@gmail.com>>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
13
script/build-dist.sh
Executable file
13
script/build-dist.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SRC_PATH="src/main/ua-parser.js"
|
||||
MIN_PATH="dist/ua-parser.min.js"
|
||||
PACK_PATH="dist/ua-parser.pack.js"
|
||||
|
||||
# minified
|
||||
echo "Generate ${MIN_PATH}"
|
||||
uglifyjs $SRC_PATH -o $MIN_PATH --comments "/^ UA/"
|
||||
|
||||
# packed
|
||||
echo "Generate ${PACK_PATH}"
|
||||
uglifyjs $SRC_PATH -o $PACK_PATH --comments "/^ UA/" --compress --mangle
|
||||
52
script/build-module.js
Executable file
52
script/build-module.js
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env node
|
||||
/* jshint esversion: 6 */
|
||||
const fs = require('fs');
|
||||
|
||||
const generateMJS = (module) => {
|
||||
let { src, dest, title, replacements } = module;
|
||||
let text = fs.readFileSync(src, 'utf-8');
|
||||
|
||||
replacements.push(
|
||||
[/const (.+?)\s*=\s*require\((.+)\)/ig, 'import $1 from $2'],
|
||||
[/module\.exports =/ig, 'export']
|
||||
);
|
||||
replacements.forEach(rep => {
|
||||
text = text.replace(rep[0], rep[1]);
|
||||
});
|
||||
|
||||
console.log(`Generate ${dest}`);
|
||||
|
||||
fs.writeFileSync(dest,
|
||||
`// Generated ESM version of ${title}
|
||||
// DO NOT EDIT THIS FILE!
|
||||
// Source: /${src}
|
||||
|
||||
${text}`, 'utf-8');
|
||||
|
||||
};
|
||||
|
||||
const modules = [
|
||||
{
|
||||
src : 'src/main/ua-parser.js',
|
||||
dest : 'src/main/ua-parser.mjs',
|
||||
title : 'ua-parser-js',
|
||||
replacements : [
|
||||
[/\(func[\s\S]+strict\';/ig, ''],
|
||||
[/esversion\: 3/ig, 'esversion: 6'],
|
||||
[/\/[\/\s]+export[\s\S]+/ig,'export {UAParser};']
|
||||
]
|
||||
},{
|
||||
src : 'src/enums/ua-parser-enums.js',
|
||||
dest :'src/enums/ua-parser-enums.mjs',
|
||||
title : 'ua-parser-js/enums',
|
||||
replacements : []
|
||||
},
|
||||
{
|
||||
src : 'src/extensions/ua-parser-extensions.js',
|
||||
dest : 'src/extensions/ua-parser-extensions.mjs',
|
||||
title : 'ua-parser-js/extensions',
|
||||
replacements : []
|
||||
}
|
||||
];
|
||||
|
||||
modules.forEach(module => generateMJS(module));
|
||||
32
script/test-all.sh
Executable file
32
script/test-all.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo '
|
||||
- run build
|
||||
'
|
||||
npm run build || exit 1
|
||||
|
||||
echo '
|
||||
- lint js code
|
||||
'
|
||||
npm run test:jshint || exit 1
|
||||
#npm run test:eslint || exit 1
|
||||
|
||||
echo '
|
||||
- test using mocha
|
||||
'
|
||||
npm run test:mocha || exit 1
|
||||
|
||||
echo '
|
||||
- test using playwright
|
||||
'
|
||||
npm run test:playwright || exit 1
|
||||
|
||||
echo '
|
||||
- lint lockfile
|
||||
'
|
||||
npm run test:lockfile-lint || exit 1
|
||||
|
||||
echo '
|
||||
- lint d.ts files
|
||||
'
|
||||
npm run test:dts || exit 1
|
||||
236
src/enums/ua-parser-enums.js
Normal file
236
src/enums/ua-parser-enums.js
Normal file
@@ -0,0 +1,236 @@
|
||||
///////////////////////////////////////////////
|
||||
/* Enums for UAParser.js v2.0.0-beta.1
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
UAParser.js PRO Enterorise License */
|
||||
//////////////////////////////////////////////
|
||||
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const Browser = Object.freeze({
|
||||
ANDROID: 'Android Browser',
|
||||
BRAVE: 'Brave',
|
||||
CHROME: 'Chrome',
|
||||
CHROMIUM: 'Chromium',
|
||||
DOLPHIN: 'Dolphin',
|
||||
DUCKDUCKGO: 'DuckDuckGo',
|
||||
EDGE: 'Edge',
|
||||
FIREFOX: 'Firefox',
|
||||
FOCUS: 'Focus',
|
||||
IE: 'IE',
|
||||
KONQUEROR: 'Konqueror',
|
||||
MOBILE_CHROME: 'Mobile Chrome',
|
||||
MOBILE_FIREFOX: 'Mobile Firefox',
|
||||
MOBILE_SAFARI: 'Mobile Safari',
|
||||
OPERA: 'Opera',
|
||||
PALEMOON: 'PaleMoon',
|
||||
PUFFIN: 'Puffin',
|
||||
QQ: 'QQ Browser',
|
||||
SAFARI: 'Safari',
|
||||
SAMSUNG: 'Samsung Internet',
|
||||
UC: 'UC Browser',
|
||||
VIVALDI: 'Vivaldi',
|
||||
YANDEX: 'Yandex'
|
||||
|
||||
// TODO : test!
|
||||
});
|
||||
|
||||
const CPU = Object.freeze({
|
||||
ARM : 'arm',
|
||||
ARM64: 'arm64',
|
||||
ARMHF: 'armhf',
|
||||
AVR: 'avr',
|
||||
IA64: 'ia64',
|
||||
IRIX: 'irix',
|
||||
IRIX64: 'irix64',
|
||||
MIPS: 'mips',
|
||||
MIPS64: 'mips64',
|
||||
MOTO_68K: '68k',
|
||||
PPC: 'ppc',
|
||||
SPARC: 'sparc',
|
||||
SPARC64: 'sparc64',
|
||||
X86: 'ia32',
|
||||
X86_64: 'amd64'
|
||||
});
|
||||
|
||||
const Device = Object.freeze({
|
||||
CONSOLE: 'console',
|
||||
DEKSTOP: 'desktop',
|
||||
EMBEDDED: 'embedded',
|
||||
MOBILE: 'mobile',
|
||||
SMARTTV: 'smarttv',
|
||||
TABLET: 'tablet',
|
||||
WEARABLE: 'wearable'
|
||||
});
|
||||
|
||||
const Vendor = Object.freeze({
|
||||
ACER: 'Acer',
|
||||
ALCATEL: 'Alcatel',
|
||||
APPLE: 'Apple',
|
||||
AMAZON: 'Amazon',
|
||||
ARCHOS: 'Archos',
|
||||
ASUS: 'ASUS',
|
||||
ATT: 'AT&T',
|
||||
BENQ: 'BenQ',
|
||||
BLACKBERRY: 'BlackBerry',
|
||||
DELL: 'Dell',
|
||||
ESSENTIAL: 'Essential',
|
||||
FACEBOOK: 'Facebook',
|
||||
FAIRPHONE: 'Fairphone',
|
||||
GEEKSPHONE: 'GeeksPhone',
|
||||
GENERIC: 'Generic',
|
||||
GOOGLE: 'Google',
|
||||
HP: 'HP',
|
||||
HTC: 'HTC',
|
||||
HUAWEI: 'Huawei',
|
||||
INFINIX: 'Infinix',
|
||||
JOLLA: 'Jolla',
|
||||
KOBO: 'Kobo',
|
||||
LENOVO: 'Lenovo',
|
||||
LG: 'LG',
|
||||
MEIZU: 'Meizu',
|
||||
MICROSOFT: 'Microsoft',
|
||||
MOTOROLA: 'Motorola',
|
||||
NEXIAN: 'Nexian',
|
||||
NINTENDO: 'Nintendo',
|
||||
NOKIA: 'Nokia',
|
||||
NVIDIA: 'Nvidia',
|
||||
ONEPLUS: 'OnePlus',
|
||||
OPPO: 'OPPO',
|
||||
OUYA: 'Ouya',
|
||||
PALM: 'Palm',
|
||||
PANASONIC: 'Panasonic',
|
||||
PEBBLE: 'Pebble',
|
||||
POLYTRON: 'Polytron',
|
||||
REALME: 'Realme',
|
||||
RIM: 'RIM',
|
||||
ROKU: 'Roku',
|
||||
SAMSUNG: 'Samsung',
|
||||
SHARP: 'Sharp',
|
||||
SIEMENS: 'Siemens',
|
||||
SONY: 'Sony',
|
||||
SPRINT: 'Sprint',
|
||||
TECNO: 'Tecno',
|
||||
TESLA: 'Tesla',
|
||||
ULEFONE: 'Ulefone',
|
||||
VIVO: 'Vivo',
|
||||
VODAFONE: 'Vodafone',
|
||||
XBOX: 'Xbox',
|
||||
XIAOMI: 'Xiaomi',
|
||||
ZEBRA: 'Zebra',
|
||||
ZTE: 'ZTE',
|
||||
|
||||
// TODO : test!
|
||||
});
|
||||
|
||||
const Engine = Object.freeze({
|
||||
AMAYA: 'Amaya',
|
||||
BLINK: 'Blink',
|
||||
EDGEHTML: 'EdgeHTML',
|
||||
FLOW: 'Flow',
|
||||
GECKO: 'Gecko',
|
||||
GOANNA: 'Goanna',
|
||||
ICAB: 'iCab',
|
||||
KHTML: 'KHTML',
|
||||
LIBWEB: 'LibWeb',
|
||||
LINKS: 'Links',
|
||||
LYNX: 'Lynx',
|
||||
NETFRONT: 'NetFront',
|
||||
NETSURF: 'NetSurf',
|
||||
PRESTO: 'Presto',
|
||||
TASMAN: 'Tasman',
|
||||
TRIDENT: 'Trident',
|
||||
W3M: 'w3m',
|
||||
WEBKIT: 'WebKit'
|
||||
});
|
||||
|
||||
const OS = Object.freeze({
|
||||
AIX: 'AIX',
|
||||
AMIGA_OS: 'Amiga OS',
|
||||
ANDROID: 'Android',
|
||||
ANDROID_X86: 'Android-x86',
|
||||
ARCH: 'Arch',
|
||||
BADA: 'Bada',
|
||||
BEOS: 'BeOS',
|
||||
BLACKBERRY: 'BlackBerry',
|
||||
CENTOS: 'CentOS',
|
||||
CHROME_OS: 'Chrome OS',
|
||||
CONTIKI: 'Contiki',
|
||||
FEDORA: 'Fedora',
|
||||
FIREFOX_OS: 'Firefox OS',
|
||||
FREEBSD: 'FreeBSD',
|
||||
DEBIAN: 'Debian',
|
||||
DEEPIN: 'Deepin',
|
||||
DRAGONFLY: 'DragonFly',
|
||||
ELEMENTARY_OS: 'elementary OS',
|
||||
FUCHSIA: 'Fuchsia',
|
||||
GENTOO: 'Gentoo',
|
||||
GHOSTBSD: 'GhostBSD',
|
||||
GNU: 'GNU',
|
||||
HAIKU: 'Haiku',
|
||||
HARMONYOS: 'HarmonyOS',
|
||||
HP_UX: 'HP-UX',
|
||||
HURD: 'Hurd',
|
||||
IOS: 'iOS',
|
||||
JOLI: 'Joli',
|
||||
KAIOS: 'KaiOS',
|
||||
LINPUS: 'Linpus',
|
||||
LINSPIRE: 'Linspire',
|
||||
LINUX: 'Linux',
|
||||
MACOS: 'macOS',
|
||||
MAEMO: 'Maemo',
|
||||
MAGEIA: 'Mageia',
|
||||
MANDRIVA: 'Mandriva',
|
||||
MANJARO: 'Manjaro',
|
||||
MEEGO: 'MeeGo',
|
||||
MINIX: 'Minix',
|
||||
MINT: 'Mint',
|
||||
MORPH_OS: 'Morph OS',
|
||||
NETBSD: 'NetBSD',
|
||||
NETRANGE: 'NetRange',
|
||||
NETTV: 'NetTV',
|
||||
NINTENDO: 'Nintendo',
|
||||
OPENBSD: 'OpenBSD',
|
||||
OPENVMS: 'OpenVMS',
|
||||
OS2: 'OS/2',
|
||||
PALM: 'Palm',
|
||||
PC_BSD: 'PC-BSD',
|
||||
PCLINUXOS: 'PCLinuxOS',
|
||||
PLAN9: 'Plan9',
|
||||
PLAYSTATION: 'PlayStation',
|
||||
QNX: 'QNX',
|
||||
RASPBIAN: 'Raspbian',
|
||||
REDHAT: 'RedHat',
|
||||
RIM_TABLET_OS: 'RIM Tablet OS',
|
||||
RISC_OS: 'RISC OS',
|
||||
SABAYON: 'Sabayon',
|
||||
SAILFISH: 'Sailfish',
|
||||
SERENITYOS: 'SerenityOS',
|
||||
SERIES40: 'Series40',
|
||||
SLACKWARE: 'Slackware',
|
||||
SOLARIS: 'Solaris',
|
||||
SUSE: 'SUSE',
|
||||
SYMBIAN: 'Symbian',
|
||||
TIZEN: 'Tizen',
|
||||
UBUNTU: 'Ubuntu',
|
||||
UNIX: 'Unix',
|
||||
VECTORLINUX: 'VectorLinux',
|
||||
VIERA: 'Viera',
|
||||
WATCHOS: 'watchOS',
|
||||
WEBOS: 'WebOS',
|
||||
WINDOWS: 'Windows',
|
||||
WINDOWS_MOBILE: 'Windows Mobile',
|
||||
WINDOWS_PHONE: 'Windows Phone',
|
||||
ZENWALK: 'Zenwalk'
|
||||
|
||||
// TODO : test!
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
Browser,
|
||||
CPU,
|
||||
Device,
|
||||
Vendor,
|
||||
Engine,
|
||||
OS
|
||||
};
|
||||
240
src/enums/ua-parser-enums.mjs
Normal file
240
src/enums/ua-parser-enums.mjs
Normal file
@@ -0,0 +1,240 @@
|
||||
// Generated ESM version of ua-parser-js/enums
|
||||
// DO NOT EDIT THIS FILE!
|
||||
// Source: /src/enums/ua-parser-enums.js
|
||||
|
||||
///////////////////////////////////////////////
|
||||
/* Enums for UAParser.js v2.0.0-beta.1
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
UAParser.js PRO Enterorise License */
|
||||
//////////////////////////////////////////////
|
||||
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const Browser = Object.freeze({
|
||||
ANDROID: 'Android Browser',
|
||||
BRAVE: 'Brave',
|
||||
CHROME: 'Chrome',
|
||||
CHROMIUM: 'Chromium',
|
||||
DOLPHIN: 'Dolphin',
|
||||
DUCKDUCKGO: 'DuckDuckGo',
|
||||
EDGE: 'Edge',
|
||||
FIREFOX: 'Firefox',
|
||||
FOCUS: 'Focus',
|
||||
IE: 'IE',
|
||||
KONQUEROR: 'Konqueror',
|
||||
MOBILE_CHROME: 'Mobile Chrome',
|
||||
MOBILE_FIREFOX: 'Mobile Firefox',
|
||||
MOBILE_SAFARI: 'Mobile Safari',
|
||||
OPERA: 'Opera',
|
||||
PALEMOON: 'PaleMoon',
|
||||
PUFFIN: 'Puffin',
|
||||
QQ: 'QQ Browser',
|
||||
SAFARI: 'Safari',
|
||||
SAMSUNG: 'Samsung Internet',
|
||||
UC: 'UC Browser',
|
||||
VIVALDI: 'Vivaldi',
|
||||
YANDEX: 'Yandex'
|
||||
|
||||
// TODO : test!
|
||||
});
|
||||
|
||||
const CPU = Object.freeze({
|
||||
ARM : 'arm',
|
||||
ARM64: 'arm64',
|
||||
ARMHF: 'armhf',
|
||||
AVR: 'avr',
|
||||
IA64: 'ia64',
|
||||
IRIX: 'irix',
|
||||
IRIX64: 'irix64',
|
||||
MIPS: 'mips',
|
||||
MIPS64: 'mips64',
|
||||
MOTO_68K: '68k',
|
||||
PPC: 'ppc',
|
||||
SPARC: 'sparc',
|
||||
SPARC64: 'sparc64',
|
||||
X86: 'ia32',
|
||||
X86_64: 'amd64'
|
||||
});
|
||||
|
||||
const Device = Object.freeze({
|
||||
CONSOLE: 'console',
|
||||
DEKSTOP: 'desktop',
|
||||
EMBEDDED: 'embedded',
|
||||
MOBILE: 'mobile',
|
||||
SMARTTV: 'smarttv',
|
||||
TABLET: 'tablet',
|
||||
WEARABLE: 'wearable'
|
||||
});
|
||||
|
||||
const Vendor = Object.freeze({
|
||||
ACER: 'Acer',
|
||||
ALCATEL: 'Alcatel',
|
||||
APPLE: 'Apple',
|
||||
AMAZON: 'Amazon',
|
||||
ARCHOS: 'Archos',
|
||||
ASUS: 'ASUS',
|
||||
ATT: 'AT&T',
|
||||
BENQ: 'BenQ',
|
||||
BLACKBERRY: 'BlackBerry',
|
||||
DELL: 'Dell',
|
||||
ESSENTIAL: 'Essential',
|
||||
FACEBOOK: 'Facebook',
|
||||
FAIRPHONE: 'Fairphone',
|
||||
GEEKSPHONE: 'GeeksPhone',
|
||||
GENERIC: 'Generic',
|
||||
GOOGLE: 'Google',
|
||||
HP: 'HP',
|
||||
HTC: 'HTC',
|
||||
HUAWEI: 'Huawei',
|
||||
INFINIX: 'Infinix',
|
||||
JOLLA: 'Jolla',
|
||||
KOBO: 'Kobo',
|
||||
LENOVO: 'Lenovo',
|
||||
LG: 'LG',
|
||||
MEIZU: 'Meizu',
|
||||
MICROSOFT: 'Microsoft',
|
||||
MOTOROLA: 'Motorola',
|
||||
NEXIAN: 'Nexian',
|
||||
NINTENDO: 'Nintendo',
|
||||
NOKIA: 'Nokia',
|
||||
NVIDIA: 'Nvidia',
|
||||
ONEPLUS: 'OnePlus',
|
||||
OPPO: 'OPPO',
|
||||
OUYA: 'Ouya',
|
||||
PALM: 'Palm',
|
||||
PANASONIC: 'Panasonic',
|
||||
PEBBLE: 'Pebble',
|
||||
POLYTRON: 'Polytron',
|
||||
REALME: 'Realme',
|
||||
RIM: 'RIM',
|
||||
ROKU: 'Roku',
|
||||
SAMSUNG: 'Samsung',
|
||||
SHARP: 'Sharp',
|
||||
SIEMENS: 'Siemens',
|
||||
SONY: 'Sony',
|
||||
SPRINT: 'Sprint',
|
||||
TECNO: 'Tecno',
|
||||
TESLA: 'Tesla',
|
||||
ULEFONE: 'Ulefone',
|
||||
VIVO: 'Vivo',
|
||||
VODAFONE: 'Vodafone',
|
||||
XBOX: 'Xbox',
|
||||
XIAOMI: 'Xiaomi',
|
||||
ZEBRA: 'Zebra',
|
||||
ZTE: 'ZTE',
|
||||
|
||||
// TODO : test!
|
||||
});
|
||||
|
||||
const Engine = Object.freeze({
|
||||
AMAYA: 'Amaya',
|
||||
BLINK: 'Blink',
|
||||
EDGEHTML: 'EdgeHTML',
|
||||
FLOW: 'Flow',
|
||||
GECKO: 'Gecko',
|
||||
GOANNA: 'Goanna',
|
||||
ICAB: 'iCab',
|
||||
KHTML: 'KHTML',
|
||||
LIBWEB: 'LibWeb',
|
||||
LINKS: 'Links',
|
||||
LYNX: 'Lynx',
|
||||
NETFRONT: 'NetFront',
|
||||
NETSURF: 'NetSurf',
|
||||
PRESTO: 'Presto',
|
||||
TASMAN: 'Tasman',
|
||||
TRIDENT: 'Trident',
|
||||
W3M: 'w3m',
|
||||
WEBKIT: 'WebKit'
|
||||
});
|
||||
|
||||
const OS = Object.freeze({
|
||||
AIX: 'AIX',
|
||||
AMIGA_OS: 'Amiga OS',
|
||||
ANDROID: 'Android',
|
||||
ANDROID_X86: 'Android-x86',
|
||||
ARCH: 'Arch',
|
||||
BADA: 'Bada',
|
||||
BEOS: 'BeOS',
|
||||
BLACKBERRY: 'BlackBerry',
|
||||
CENTOS: 'CentOS',
|
||||
CHROME_OS: 'Chrome OS',
|
||||
CONTIKI: 'Contiki',
|
||||
FEDORA: 'Fedora',
|
||||
FIREFOX_OS: 'Firefox OS',
|
||||
FREEBSD: 'FreeBSD',
|
||||
DEBIAN: 'Debian',
|
||||
DEEPIN: 'Deepin',
|
||||
DRAGONFLY: 'DragonFly',
|
||||
ELEMENTARY_OS: 'elementary OS',
|
||||
FUCHSIA: 'Fuchsia',
|
||||
GENTOO: 'Gentoo',
|
||||
GHOSTBSD: 'GhostBSD',
|
||||
GNU: 'GNU',
|
||||
HAIKU: 'Haiku',
|
||||
HARMONYOS: 'HarmonyOS',
|
||||
HP_UX: 'HP-UX',
|
||||
HURD: 'Hurd',
|
||||
IOS: 'iOS',
|
||||
JOLI: 'Joli',
|
||||
KAIOS: 'KaiOS',
|
||||
LINPUS: 'Linpus',
|
||||
LINSPIRE: 'Linspire',
|
||||
LINUX: 'Linux',
|
||||
MACOS: 'macOS',
|
||||
MAEMO: 'Maemo',
|
||||
MAGEIA: 'Mageia',
|
||||
MANDRIVA: 'Mandriva',
|
||||
MANJARO: 'Manjaro',
|
||||
MEEGO: 'MeeGo',
|
||||
MINIX: 'Minix',
|
||||
MINT: 'Mint',
|
||||
MORPH_OS: 'Morph OS',
|
||||
NETBSD: 'NetBSD',
|
||||
NETRANGE: 'NetRange',
|
||||
NETTV: 'NetTV',
|
||||
NINTENDO: 'Nintendo',
|
||||
OPENBSD: 'OpenBSD',
|
||||
OPENVMS: 'OpenVMS',
|
||||
OS2: 'OS/2',
|
||||
PALM: 'Palm',
|
||||
PC_BSD: 'PC-BSD',
|
||||
PCLINUXOS: 'PCLinuxOS',
|
||||
PLAN9: 'Plan9',
|
||||
PLAYSTATION: 'PlayStation',
|
||||
QNX: 'QNX',
|
||||
RASPBIAN: 'Raspbian',
|
||||
REDHAT: 'RedHat',
|
||||
RIM_TABLET_OS: 'RIM Tablet OS',
|
||||
RISC_OS: 'RISC OS',
|
||||
SABAYON: 'Sabayon',
|
||||
SAILFISH: 'Sailfish',
|
||||
SERENITYOS: 'SerenityOS',
|
||||
SERIES40: 'Series40',
|
||||
SLACKWARE: 'Slackware',
|
||||
SOLARIS: 'Solaris',
|
||||
SUSE: 'SUSE',
|
||||
SYMBIAN: 'Symbian',
|
||||
TIZEN: 'Tizen',
|
||||
UBUNTU: 'Ubuntu',
|
||||
UNIX: 'Unix',
|
||||
VECTORLINUX: 'VectorLinux',
|
||||
VIERA: 'Viera',
|
||||
WATCHOS: 'watchOS',
|
||||
WEBOS: 'WebOS',
|
||||
WINDOWS: 'Windows',
|
||||
WINDOWS_MOBILE: 'Windows Mobile',
|
||||
WINDOWS_PHONE: 'Windows Phone',
|
||||
ZENWALK: 'Zenwalk'
|
||||
|
||||
// TODO : test!
|
||||
});
|
||||
|
||||
export {
|
||||
Browser,
|
||||
CPU,
|
||||
Device,
|
||||
Vendor,
|
||||
Engine,
|
||||
OS
|
||||
};
|
||||
248
src/extensions/ua-parser-extensions.js
Normal file
248
src/extensions/ua-parser-extensions.js
Normal file
@@ -0,0 +1,248 @@
|
||||
///////////////////////////////////////////////
|
||||
/* Extensions for UAParser.js v2.0.0-beta.1
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
UAParser.js PRO Enterorise License */
|
||||
//////////////////////////////////////////////
|
||||
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const MODEL = 'model';
|
||||
const NAME = 'name';
|
||||
const TYPE = 'type';
|
||||
const VENDOR = 'vendor';
|
||||
const VERSION = 'version';
|
||||
const MOBILE = 'mobile';
|
||||
const TABLET = 'tablet';
|
||||
|
||||
const Apps = Object.freeze({
|
||||
browser : [
|
||||
[/chatlyio\/([\d\.]+)/i], [VERSION, 'Slack', [TYPE, 'app']]
|
||||
]
|
||||
});
|
||||
|
||||
const Bots = Object.freeze({
|
||||
browser : [
|
||||
// Googlebot / BingBot / MSNBot / FacebookBot
|
||||
[/((?:google|bing|msn|facebook)bot(?:[\-imagevdo]{0,6})|bingpreview)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']],
|
||||
|
||||
// GPTBot - https://platform.openai.com/docs/gptbot
|
||||
[/(gptbot)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']],
|
||||
|
||||
// Slackbot - https://api.slack.com/robots
|
||||
[/(slack(?:bot)?(?:-imgproxy|-linkexpanding)?) ([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']]
|
||||
]
|
||||
});
|
||||
|
||||
const CLIs = Object.freeze({
|
||||
browser : [
|
||||
// wget / curl / lynx
|
||||
[/(wget|curl|lynx)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'cli']]
|
||||
]
|
||||
});
|
||||
|
||||
const ExtraDevices = Object.freeze({
|
||||
device : [[
|
||||
/(nook)[\w ]+build\/(\w+)/i, // Nook
|
||||
/(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
|
||||
/(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
|
||||
/(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
|
||||
/(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
|
||||
/(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
|
||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
||||
|
||||
/(u304aa)/i // AT&T
|
||||
], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
|
||||
|
||||
/\bsie-(\w*)/i // Siemens
|
||||
], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(rct\w+) b/i // RCA Tablets
|
||||
], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
|
||||
], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
|
||||
], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
|
||||
], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(tm\d{3}\w+) b/i
|
||||
], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(k88) b/i // ZTE K Series Tablet
|
||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(nx\d{3}j) b/i // ZTE Nubia
|
||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
|
||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(zur\d{3}) b/i // Swiss ZUR Tablet
|
||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
|
||||
|
||||
/\b((zeki)?tb.*\b) b/i // Zeki Tablets
|
||||
], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
|
||||
|
||||
/\b([yr]\d{2}) b/i,
|
||||
/\b(?:dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
|
||||
], [MODEL, [VENDOR, 'Dragon Touch'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(ns-?\w{0,9}) b/i // Insignia Tablets
|
||||
], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
|
||||
|
||||
/\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
|
||||
], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
|
||||
], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
|
||||
], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/\b(ph-1) /i // Essential PH-1
|
||||
], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
|
||||
], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
|
||||
], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
|
||||
|
||||
/\btu_(1491) b/i // Rotor Tablets
|
||||
], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]]
|
||||
]
|
||||
});
|
||||
|
||||
const Emails = Object.freeze({
|
||||
browser : [
|
||||
// Microsoft Outlook / Thunderbird
|
||||
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, 'email']]
|
||||
]
|
||||
});
|
||||
|
||||
const MediaPlayers = Object.freeze({
|
||||
browser : [[
|
||||
|
||||
/(apple(?:coremedia|))\/([\w\._]+)/i, // Generic Apple CoreMedia
|
||||
/(coremedia) v([\w\._]+)/i
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(aqualung|lyssna|bsplayer)\/([\w\.-]+)/i // Aqualung/Lyssna/BSPlayer
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(ares|ossproxy)\s([\w\.-]+)/i // Ares/OSSProxy
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(audacious|audimusicstream|amarok|bass|core|dalvik|gnomemplayer|music on console|nsplayer|psp-internetradioplayer|videos)\/([\w\.-]+)/i,
|
||||
// Audacious/AudiMusicStream/Amarok/BASS/OpenCORE/Dalvik/GnomeMplayer/MoC
|
||||
// NSPlayer/PSP-InternetRadioPlayer/Videos
|
||||
/(clementine|music player daemon)\s([\w\.-]+)/i, // Clementine/MPD
|
||||
/(lg player|nexplayer)\s([\d\.]+)/i,
|
||||
/player\/(nexplayer|lg player)\s([\w\.-]+)/i // NexPlayer/LG Player
|
||||
], [NAME, VERSION], [
|
||||
/(nexplayer)\s([\w\.-]+)/i // Nexplayer
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(flrp)\/([\w\.-]+)/i // Flip Player
|
||||
], [[NAME, 'Flip Player'], VERSION], [
|
||||
|
||||
/(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i
|
||||
// FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit
|
||||
], [NAME], [
|
||||
|
||||
/(gstreamer) souphttpsrc.+libsoup\/([\w\.-]+)/i
|
||||
// Gstreamer
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(htc streaming player)\s[\w_]+\s\/\s([\d\.]+)/i, // HTC Streaming Player
|
||||
/(java|python-urllib|python-requests|wget|libcurl)\/([\w\.-_]+)/i,
|
||||
// Java/urllib/requests/wget/cURL
|
||||
/(lavf)([\d\.]+)/i // Lavf (FFMPEG)
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(htc_one_s)\/([\d\.]+)/i, // HTC One S
|
||||
], [[NAME, /_/g, ' '], VERSION], [
|
||||
|
||||
/(mplayer)(?:\s|\/)(?:(?:sherpya-){0,1}svn)(?:-|\s)(r\d+(?:-\d+[\w\.-]+))/i,
|
||||
// MPlayer SVN
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(mplayer)(?:\s|\/)([\w\.-]+)/i, // MPlayer
|
||||
/(mplayer) unknown-([\w\.\-]+)/i // MPlayer UNKNOWN
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(mplayer)/i, // MPlayer (no other info)
|
||||
/(yourmuze)/i, // YourMuze
|
||||
/(media player classic|nero showtime)/i // Media Player Classic/Nero ShowTime
|
||||
], [NAME], [
|
||||
|
||||
/(nero (?:home|scout))\/([\w\.-]+)/i // Nero Home/Nero Scout
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(nokia\d+)\/([\w\.-]+)/i // Nokia
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/\s(songbird)\/([\w\.-]+)/i // Songbird/Philips-Songbird
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(winamp)3 version ([\w\.-]+)/i, // Winamp
|
||||
/(winamp)\s([\w\.-]+)/i,
|
||||
/(winamp)mpeg\/([\w\.-]+)/i
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(ocms-bot|tapinradio|tunein radio|unknown|winamp|inlight radio)/i // OCMS-bot/tap in radio/tunein/unknown/winamp (no other info)
|
||||
// inlight radio
|
||||
], [NAME], [
|
||||
|
||||
/(quicktime|rma|radioapp|radioclientapplication|soundtap|totem|stagefright|streamium)\/([\w\.-]+)/i
|
||||
// QuickTime/RealMedia/RadioApp/RadioClientApplication/
|
||||
// SoundTap/Totem/Stagefright/Streamium
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(smp)([\d\.]+)/i // SMP
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(vlc) media player - version ([\w\.]+)/i, // VLC Videolan
|
||||
/(vlc)\/([\w\.-]+)/i,
|
||||
/(xbmc|gvfs|xine|xmms|irapp)\/([\w\.-]+)/i, // XBMC/gvfs/Xine/XMMS/irapp
|
||||
/(foobar2000)\/([\d\.]+)/i, // Foobar2000
|
||||
/(itunes)\/([\d\.]+)/i // iTunes
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(wmplayer)\/([\w\.-]+)/i, // Windows Media Player
|
||||
/(windows-media-player)\/([\w\.-]+)/i
|
||||
], [[NAME, /-/g, ' '], VERSION], [
|
||||
|
||||
/windows\/([\w\.-]+) upnp\/[\d\.]+ dlnadoc\/[\d\.]+ (home media server)/i,
|
||||
// Windows Media Server
|
||||
], [VERSION, [NAME, 'Windows']], [
|
||||
|
||||
/(com\.riseupradioalarm)\/([\d\.]*)/i // RiseUP Radio Alarm
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(rad.io)\s([\d\.]+)/i, // Rad.io
|
||||
/(radio.(?:de|at|fr))\s([\d\.]+)/i
|
||||
], [[NAME, 'rad.io'], VERSION]
|
||||
]
|
||||
});
|
||||
|
||||
const Modules = Object.freeze({
|
||||
browser : [
|
||||
// Axios/jsdom/Scrapy
|
||||
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'module']]
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
Apps,
|
||||
Bots,
|
||||
CLIs,
|
||||
ExtraDevices,
|
||||
Emails,
|
||||
MediaPlayers,
|
||||
Modules
|
||||
};
|
||||
252
src/extensions/ua-parser-extensions.mjs
Normal file
252
src/extensions/ua-parser-extensions.mjs
Normal file
@@ -0,0 +1,252 @@
|
||||
// Generated ESM version of ua-parser-js/extensions
|
||||
// DO NOT EDIT THIS FILE!
|
||||
// Source: /src/extensions/ua-parser-extensions.js
|
||||
|
||||
///////////////////////////////////////////////
|
||||
/* Extensions for UAParser.js v2.0.0-beta.1
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
UAParser.js PRO Enterorise License */
|
||||
//////////////////////////////////////////////
|
||||
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const MODEL = 'model';
|
||||
const NAME = 'name';
|
||||
const TYPE = 'type';
|
||||
const VENDOR = 'vendor';
|
||||
const VERSION = 'version';
|
||||
const MOBILE = 'mobile';
|
||||
const TABLET = 'tablet';
|
||||
|
||||
const Apps = Object.freeze({
|
||||
browser : [
|
||||
[/chatlyio\/([\d\.]+)/i], [VERSION, 'Slack', [TYPE, 'app']]
|
||||
]
|
||||
});
|
||||
|
||||
const Bots = Object.freeze({
|
||||
browser : [
|
||||
// Googlebot / BingBot / MSNBot / FacebookBot
|
||||
[/((?:google|bing|msn|facebook)bot(?:[\-imagevdo]{0,6})|bingpreview)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']],
|
||||
|
||||
// GPTBot - https://platform.openai.com/docs/gptbot
|
||||
[/(gptbot)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']],
|
||||
|
||||
// Slackbot - https://api.slack.com/robots
|
||||
[/(slack(?:bot)?(?:-imgproxy|-linkexpanding)?) ([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']]
|
||||
]
|
||||
});
|
||||
|
||||
const CLIs = Object.freeze({
|
||||
browser : [
|
||||
// wget / curl / lynx
|
||||
[/(wget|curl|lynx)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'cli']]
|
||||
]
|
||||
});
|
||||
|
||||
const ExtraDevices = Object.freeze({
|
||||
device : [[
|
||||
/(nook)[\w ]+build\/(\w+)/i, // Nook
|
||||
/(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
|
||||
/(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
|
||||
/(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
|
||||
/(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
|
||||
/(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
|
||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
||||
|
||||
/(u304aa)/i // AT&T
|
||||
], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
|
||||
|
||||
/\bsie-(\w*)/i // Siemens
|
||||
], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(rct\w+) b/i // RCA Tablets
|
||||
], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
|
||||
], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
|
||||
], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
|
||||
], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(tm\d{3}\w+) b/i
|
||||
], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(k88) b/i // ZTE K Series Tablet
|
||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(nx\d{3}j) b/i // ZTE Nubia
|
||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
|
||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(zur\d{3}) b/i // Swiss ZUR Tablet
|
||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
|
||||
|
||||
/\b((zeki)?tb.*\b) b/i // Zeki Tablets
|
||||
], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
|
||||
|
||||
/\b([yr]\d{2}) b/i,
|
||||
/\b(?:dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
|
||||
], [MODEL, [VENDOR, 'Dragon Touch'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(ns-?\w{0,9}) b/i // Insignia Tablets
|
||||
], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
|
||||
|
||||
/\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
|
||||
], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
|
||||
], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
|
||||
], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/\b(ph-1) /i // Essential PH-1
|
||||
], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
|
||||
|
||||
/\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
|
||||
], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
|
||||
|
||||
/\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
|
||||
], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
|
||||
|
||||
/\btu_(1491) b/i // Rotor Tablets
|
||||
], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]]
|
||||
]
|
||||
});
|
||||
|
||||
const Emails = Object.freeze({
|
||||
browser : [
|
||||
// Microsoft Outlook / Thunderbird
|
||||
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, 'email']]
|
||||
]
|
||||
});
|
||||
|
||||
const MediaPlayers = Object.freeze({
|
||||
browser : [[
|
||||
|
||||
/(apple(?:coremedia|))\/([\w\._]+)/i, // Generic Apple CoreMedia
|
||||
/(coremedia) v([\w\._]+)/i
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(aqualung|lyssna|bsplayer)\/([\w\.-]+)/i // Aqualung/Lyssna/BSPlayer
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(ares|ossproxy)\s([\w\.-]+)/i // Ares/OSSProxy
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(audacious|audimusicstream|amarok|bass|core|dalvik|gnomemplayer|music on console|nsplayer|psp-internetradioplayer|videos)\/([\w\.-]+)/i,
|
||||
// Audacious/AudiMusicStream/Amarok/BASS/OpenCORE/Dalvik/GnomeMplayer/MoC
|
||||
// NSPlayer/PSP-InternetRadioPlayer/Videos
|
||||
/(clementine|music player daemon)\s([\w\.-]+)/i, // Clementine/MPD
|
||||
/(lg player|nexplayer)\s([\d\.]+)/i,
|
||||
/player\/(nexplayer|lg player)\s([\w\.-]+)/i // NexPlayer/LG Player
|
||||
], [NAME, VERSION], [
|
||||
/(nexplayer)\s([\w\.-]+)/i // Nexplayer
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(flrp)\/([\w\.-]+)/i // Flip Player
|
||||
], [[NAME, 'Flip Player'], VERSION], [
|
||||
|
||||
/(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i
|
||||
// FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit
|
||||
], [NAME], [
|
||||
|
||||
/(gstreamer) souphttpsrc.+libsoup\/([\w\.-]+)/i
|
||||
// Gstreamer
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(htc streaming player)\s[\w_]+\s\/\s([\d\.]+)/i, // HTC Streaming Player
|
||||
/(java|python-urllib|python-requests|wget|libcurl)\/([\w\.-_]+)/i,
|
||||
// Java/urllib/requests/wget/cURL
|
||||
/(lavf)([\d\.]+)/i // Lavf (FFMPEG)
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(htc_one_s)\/([\d\.]+)/i, // HTC One S
|
||||
], [[NAME, /_/g, ' '], VERSION], [
|
||||
|
||||
/(mplayer)(?:\s|\/)(?:(?:sherpya-){0,1}svn)(?:-|\s)(r\d+(?:-\d+[\w\.-]+))/i,
|
||||
// MPlayer SVN
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(mplayer)(?:\s|\/)([\w\.-]+)/i, // MPlayer
|
||||
/(mplayer) unknown-([\w\.\-]+)/i // MPlayer UNKNOWN
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(mplayer)/i, // MPlayer (no other info)
|
||||
/(yourmuze)/i, // YourMuze
|
||||
/(media player classic|nero showtime)/i // Media Player Classic/Nero ShowTime
|
||||
], [NAME], [
|
||||
|
||||
/(nero (?:home|scout))\/([\w\.-]+)/i // Nero Home/Nero Scout
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(nokia\d+)\/([\w\.-]+)/i // Nokia
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/\s(songbird)\/([\w\.-]+)/i // Songbird/Philips-Songbird
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(winamp)3 version ([\w\.-]+)/i, // Winamp
|
||||
/(winamp)\s([\w\.-]+)/i,
|
||||
/(winamp)mpeg\/([\w\.-]+)/i
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(ocms-bot|tapinradio|tunein radio|unknown|winamp|inlight radio)/i // OCMS-bot/tap in radio/tunein/unknown/winamp (no other info)
|
||||
// inlight radio
|
||||
], [NAME], [
|
||||
|
||||
/(quicktime|rma|radioapp|radioclientapplication|soundtap|totem|stagefright|streamium)\/([\w\.-]+)/i
|
||||
// QuickTime/RealMedia/RadioApp/RadioClientApplication/
|
||||
// SoundTap/Totem/Stagefright/Streamium
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(smp)([\d\.]+)/i // SMP
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(vlc) media player - version ([\w\.]+)/i, // VLC Videolan
|
||||
/(vlc)\/([\w\.-]+)/i,
|
||||
/(xbmc|gvfs|xine|xmms|irapp)\/([\w\.-]+)/i, // XBMC/gvfs/Xine/XMMS/irapp
|
||||
/(foobar2000)\/([\d\.]+)/i, // Foobar2000
|
||||
/(itunes)\/([\d\.]+)/i // iTunes
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(wmplayer)\/([\w\.-]+)/i, // Windows Media Player
|
||||
/(windows-media-player)\/([\w\.-]+)/i
|
||||
], [[NAME, /-/g, ' '], VERSION], [
|
||||
|
||||
/windows\/([\w\.-]+) upnp\/[\d\.]+ dlnadoc\/[\d\.]+ (home media server)/i,
|
||||
// Windows Media Server
|
||||
], [VERSION, [NAME, 'Windows']], [
|
||||
|
||||
/(com\.riseupradioalarm)\/([\d\.]*)/i // RiseUP Radio Alarm
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(rad.io)\s([\d\.]+)/i, // Rad.io
|
||||
/(radio.(?:de|at|fr))\s([\d\.]+)/i
|
||||
], [[NAME, 'rad.io'], VERSION]
|
||||
]
|
||||
});
|
||||
|
||||
const Modules = Object.freeze({
|
||||
browser : [
|
||||
// Axios/jsdom/Scrapy
|
||||
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'module']]
|
||||
]
|
||||
});
|
||||
|
||||
export {
|
||||
Apps,
|
||||
Bots,
|
||||
CLIs,
|
||||
ExtraDevices,
|
||||
Emails,
|
||||
MediaPlayers,
|
||||
Modules
|
||||
};
|
||||
104
src/main/ua-parser.d.ts
vendored
Normal file
104
src/main/ua-parser.d.ts
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
// Type definitions for UAParser.js v2.0.0-beta.1
|
||||
// Project: https://github.com/faisalman/ua-parser-js
|
||||
// Definitions by: Faisal Salman <https://github.com/faisalman>
|
||||
|
||||
declare namespace UAParser {
|
||||
|
||||
interface IData<T> {
|
||||
is(val: string): boolean;
|
||||
toString(): string;
|
||||
withClientHints(): PromiseLike<T> | T;
|
||||
withFeatureCheck(): T;
|
||||
}
|
||||
|
||||
interface IBrowser extends IData<IBrowser> {
|
||||
name?: string;
|
||||
version?: string;
|
||||
major?: string;
|
||||
}
|
||||
|
||||
interface ICPU extends IData<ICPU> {
|
||||
architecture?: 'ia32' | 'ia64' | 'amd64' | 'arm' | 'arm64' | 'armhf' | 'avr' | 'irix' | 'irix64' | 'mips' | 'mips64' | '68k' | 'ppc' | 'sparc' | 'sparc64';
|
||||
}
|
||||
|
||||
interface IDevice extends IData<IDevice> {
|
||||
type?: 'mobile' | 'tablet' | 'console' | 'smarttv' | 'wearable';
|
||||
vendor?: string;
|
||||
model?: string;
|
||||
}
|
||||
|
||||
interface IEngine extends IData<IEngine> {
|
||||
name?: 'Amaya' | 'Blink' | 'EdgeHTML' | 'Flow' | 'Gecko' | 'Goanna' | 'iCab' | 'KHTML' | 'LibWeb' | 'Links' | 'Lynx' | 'NetFront' | 'NetSurf' | 'Presto' | 'Tasman' | 'Trident' | 'w3m' | 'WebKit';
|
||||
version?: string;
|
||||
}
|
||||
|
||||
interface IOS extends IData<IOS> {
|
||||
name?: string;
|
||||
version?: string;
|
||||
}
|
||||
|
||||
interface IResult extends IData<IResult> {
|
||||
ua: string;
|
||||
browser: IBrowser;
|
||||
cpu: ICPU;
|
||||
device: IDevice;
|
||||
engine: IEngine;
|
||||
os: IOS;
|
||||
}
|
||||
|
||||
type RegexMap = ((RegExp | string | (string | RegExp | Function)[])[])[];
|
||||
|
||||
export function UAParser(uastring?: string, extensions?: Record<string, RegexMap>, headers?: Record<string, string>): IResult;
|
||||
export function UAParser(uastring?: string, headers?: Record<string, string>): IResult;
|
||||
export function UAParser(extensions?: Record<string, RegexMap>, headers?: Record<string, string>): IResult;
|
||||
export function UAParser(headers?: Record<string, string>): IResult;
|
||||
|
||||
export class UAParser {
|
||||
|
||||
static readonly BROWSER: {
|
||||
NAME: 'name';
|
||||
VERSION: 'version';
|
||||
MAJOR: 'major';
|
||||
};
|
||||
static readonly CPU: {
|
||||
ARCHITECTURE: 'architecture';
|
||||
};
|
||||
static readonly DEVICE: {
|
||||
TYPE: 'type';
|
||||
VENDOR: 'vendor';
|
||||
MODEL: 'model';
|
||||
CONSOLE: 'console';
|
||||
MOBILE: 'mobile';
|
||||
SMARTTV: 'smarttv';
|
||||
TABLET: 'tablet';
|
||||
WEARABLE: 'wearable';
|
||||
EMBEDDED: 'embedded';
|
||||
};
|
||||
static readonly ENGINE: {
|
||||
NAME: 'name';
|
||||
VERSION: 'version';
|
||||
};
|
||||
static readonly OS: {
|
||||
NAME: 'name';
|
||||
VERSION: 'version';
|
||||
};
|
||||
static readonly VERSION: string;
|
||||
|
||||
constructor(uastring?: string, extensions?: Record<string, RegexMap>, headers?: Record<string, string>);
|
||||
constructor(uastring?: string, headers?: Record<string, string>);
|
||||
constructor(extensions?: Record<string, RegexMap>, headers?: Record<string, string>);
|
||||
constructor(headers?: Record<string, string>);
|
||||
|
||||
getUA(): string;
|
||||
getBrowser(): IBrowser;
|
||||
getCPU(): ICPU;
|
||||
getDevice(): IDevice;
|
||||
getEngine(): IEngine;
|
||||
getOS(): IOS;
|
||||
getResult(): IResult;
|
||||
setUA(uastring: string): UAParser;
|
||||
}
|
||||
}
|
||||
|
||||
export as namespace UAParser;
|
||||
export = UAParser;
|
||||
1243
src/main/ua-parser.js
Executable file
1243
src/main/ua-parser.js
Executable file
File diff suppressed because it is too large
Load Diff
1201
src/main/ua-parser.mjs
Normal file
1201
src/main/ua-parser.mjs
Normal file
File diff suppressed because it is too large
Load Diff
1089
src/ua-parser.js
1089
src/ua-parser.js
File diff suppressed because it is too large
Load Diff
@@ -1,106 +0,0 @@
|
||||
[
|
||||
{
|
||||
"desc" : "i686",
|
||||
"ua" : "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:19.0) Gecko/20100101 Firefox/19.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "i386",
|
||||
"ua" : "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040628 Epiphany/1.2.6",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "x86-64",
|
||||
"ua" : "Opera/9.80 (X11; Linux x86_64; U; Linux Mint; en) Presto/2.2.15 Version/10.10",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "win64",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Win64; x64; Trident/6.0; .NET4.0E; .NET4.0C)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WOW64",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv6",
|
||||
"ua" : "Mozilla/5.0 (X11; U; Linux armv61; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Pocket PC",
|
||||
"ua" : "Opera/9.7 (Windows Mobile; PPC; Opera Mobi/35166; U; en) Presto/2.2.1",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 5.17; Mac_PowerPC Mac OS; en)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "iCab/2.9.5 (Macintosh; U; PPC; Mac OS X)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "UltraSPARC",
|
||||
"ua" : "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "sparc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "QuickTime",
|
||||
"ua" : "QuickTime/7.5.6 (qtver=7.5.6;cpu=IA32;os=Mac 10.5.8)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "XBMC",
|
||||
"ua" : "XBMC/12.0 Git:20130127-fb595f2 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,855 +0,0 @@
|
||||
[{
|
||||
"desc": "Asus Nexus 7",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 7 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Asus",
|
||||
"model": "Nexus 7",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Asus Padfone",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.1.1; PadFone 2 Build/JRO03L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.117 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Asus",
|
||||
"model": "PadFone",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Desktop (IE11 with Tablet string)",
|
||||
"ua": "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; GWX:MANAGED; rv:11.0) like Gecko",
|
||||
"expect": {
|
||||
"vendor": "undefined",
|
||||
"model": "undefined",
|
||||
"type": "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "HTC Evo Shift 4G",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0",
|
||||
"expect": {
|
||||
"vendor": "HTC",
|
||||
"model": "Evo Shift 4G",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "HTC Nexus 9",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; Nexus 9 Build/LRX21R) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Mobile Crosswalk/7.36.154.13 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "HTC",
|
||||
"model": "Nexus 9",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Huawei Honor",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 2.3; xx-xx; U8860 Build/HuaweiU8860) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||
"expect": {
|
||||
"vendor": "Huawei",
|
||||
"model": "U8860",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Huawei Nexus 6P",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 6P Build/MTC19V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Mobile Safari/537",
|
||||
"expect": {
|
||||
"vendor": "Huawei",
|
||||
"model": "Nexus 6P",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Huawei P10",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.0; VTR-L09 Build/HUAWEIVTR-L09; xx-xx) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Huawei",
|
||||
"model": "VTR-L09",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Huawei Y3II",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 5.1; xx-xx; HUAWEI LUA-L03 Build/HUAWEILUA-L03) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Huawei",
|
||||
"model": "LUA-L03",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "iPod",
|
||||
"ua": "Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53",
|
||||
"expect": {
|
||||
"vendor": "Apple",
|
||||
"model": "iPod touch",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "LG Nexus 4",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.1; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
|
||||
"expect": {
|
||||
"vendor": "LG",
|
||||
"model": "Nexus 4",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "LG Nexus 5",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
|
||||
"expect": {
|
||||
"vendor": "LG",
|
||||
"model": "Nexus 5",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Meizu M5 Note",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0; M5 Note Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043024 Safari/537.36 MicroMessenger/6.5.7.1040 NetType/WIFI Language/zh_CN",
|
||||
"expect": {
|
||||
"vendor": "Meizu",
|
||||
"model": "M5 Note",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Microsoft Lumia 950",
|
||||
"ua": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/13.10586",
|
||||
"expect": {
|
||||
"vendor": "Microsoft",
|
||||
"model": "Lumia 950",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Motorola Moto X",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.4; XT1097 Build/KXE21.187-38) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.109 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Motorola",
|
||||
"model": "XT1097",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Motorola Nexus 6",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.20 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Motorola",
|
||||
"model": "Nexus 6",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Motorola Droid RAZR 4G",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 2.3; xx-xx; DROID RAZR 4G Build/6.5.1-73_DHD-11_M1-29) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||
"expect": {
|
||||
"vendor": "Motorola",
|
||||
"model": "DROID RAZR 4G",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "iPhone",
|
||||
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53",
|
||||
"expect": {
|
||||
"vendor": "Apple",
|
||||
"model": "iPhone",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Motorola Droid RAZR 4G",
|
||||
"ua": "Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A501 Safari/9537.53",
|
||||
"expect": {
|
||||
"vendor": "Apple",
|
||||
"model": "iPod touch",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Moto X",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.2; xx-xx; XT1058 Build/13.9.0Q2.X-70-GHOST-ATT_LE-2) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Motorola",
|
||||
"model": "XT1058",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Nokia3xx",
|
||||
"ua": "Nokia303/14.87 CLDC-1.1",
|
||||
"expect": {
|
||||
"vendor": "Nokia",
|
||||
"model": "303",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "OnePlus One",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.4; A0001 Build/KTU84Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.59 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "OnePlus",
|
||||
"model": "1",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "OnePlus 3",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A3000 Build/NMF26F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "OnePlus",
|
||||
"model": "A3000",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "OPPO R7s",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; OPPO R7s Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 Chrome/37.0.0.0 MQQBrowser/7.1 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "OPPO",
|
||||
"model": "R7s",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Philips SmartTV",
|
||||
"ua": "Opera/9.80 HbbTV/1.1.1 (; Philips; ; ; ; ) NETTV/4.0.2; en) Version/11.60",
|
||||
"expect": {
|
||||
"vendor": "Philips",
|
||||
"model": "",
|
||||
"type": "smarttv"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Kindle Fire HD",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true",
|
||||
"expect": {
|
||||
"vendor": "Amazon",
|
||||
"model": "KFTT",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung Galaxy Note 8",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; GT-N5100 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.141 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "GT-N5100",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SM-C5000",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; SM-C5000 Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/51.0.2704.81 Mobile Safari/537.36 wkbrowser 4.1.35 3065",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-C5000",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SM-T231",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; SM-T231 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-T231",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SM-T700",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; SM-T700 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-T700",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SM-T520",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; SM-T520 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-T520",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SmartTV2011",
|
||||
"ua": "HbbTV/1.1.1 (;;;;;) Maple;2011",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SmartTV2011",
|
||||
"type": "smarttv"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SmartTV2012",
|
||||
"ua": "HbbTV/1.1.1 (;Samsung;SmartTV2012;;;) WebKit",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SmartTV2012",
|
||||
"type": "smarttv"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SmartTV2014",
|
||||
"ua": "HbbTV/1.1.1 (;Samsung;SmartTV2014;T-NT14UDEUC-1060.4;;) WebKit",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SmartTV2014",
|
||||
"type": "smarttv"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung SmartTV",
|
||||
"ua": "Mozilla/5.0 (SMART-TV; Linux; Tizen 2.3) AppleWebkit/538.1 (KHTML, like Gecko) SamsungBrowser/1.0 TV Safari/538.1",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "undefined",
|
||||
"type": "smarttv"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony C5303 (Xperia SP)",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.3; C5303 Build/12.1.A.1.205) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.93 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "C5303",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony SO-02F (Xperia Z1 F)",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; SO-02F Build/14.1.H.2.119) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "SO-02F",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony D6653 (Xperia Z3)",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4; D6653 Build/23.0.A.0.376) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.141 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "D6653",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony Xperia SOL25 (ZL2)",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.4; SOL25 Build/17.1.1.C.1.64) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "SOL25",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony Xperia SP",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.3; C5302 Build/12.1.A.1.201) AppleWebkit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "C5302",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony SGP521 (Xperia Z2 Tablet)",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4; SGP521 Build/17.1.A.0.432) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "Xperia Tablet",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony Tablet S",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 3.1; Sony Tablet S Build/THMAS10000) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "Xperia Tablet",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Sony Tablet Z LTE",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1; SonySGP321 Build/10.2.C.0.143) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "Xperia Tablet",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi 2013023",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.2.2; en-US; 2013023 Build/HM2013023) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/10.0.1.512 U3/0.8.0 Mobile Safari/533.1",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "2013023",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi Hongmi Note 1W",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.2.2; zh-CN; HM NOTE 1W Build/JDQ39) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.7.9.439 U3/0.8.0 Mobile Safari/533.1",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "HM NOTE 1W",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi Mi 3C",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.3; zh-CN; MI 3C Build/JLS36C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 UCBrowser/9.7.9.439 U3/0.8.0 Mobile Safari/533.1",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "MI 3C",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi Mi 5",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.0; MI 5 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.83 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "MI 5",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi Mi 6",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.1; MI 6 Build/NMF26X; xx-xx) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/59.0.3071.125 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "MI 6",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi Mi 5s Plus",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 6.0.1; zh-cn; MI 5s Plus Build/MXB48T) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.146 Mobile Safari/537.36 XiaoMi/MiuiBrowser/8.7.1",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "MI 5s Plus",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi Mi Note",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.4; MI NOTE LTE Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "MI NOTE LTE",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi Mi One Plus",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; MI-ONE Plus Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "MI-ONE Plus",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "PlayStation 4",
|
||||
"ua": "Mozilla/5.0 (PlayStation 4 3.00) AppleWebKit/537.73 (KHTML, like Gecko)",
|
||||
"expect": {
|
||||
"vendor": "Sony",
|
||||
"model": "PlayStation 4",
|
||||
"type": "console"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Galaxy Nexus",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "Galaxy Nexus",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung Galaxy S5",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; SM-G900F Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.78 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-G900F",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung Galaxy S6",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; SM-G920I Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-G920I",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung Galaxy S6 Edge",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; SM-G925I Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.135 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-G925I",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung Galaxy Note 5 Chrome",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; SM-N920C Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-N920C",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Samsung Galaxy Note 5 Samsung Browser",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-N920C Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Samsung",
|
||||
"model": "SM-N920C",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Google Chromecast",
|
||||
"ua": "Mozilla/5.0 (X11; Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.84 Safari/537.36 CrKey/1.22.79313",
|
||||
"expect": {
|
||||
"vendor": "Google",
|
||||
"model": "Chromecast"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Google Pixel C",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.0; Pixel C Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Google",
|
||||
"model": "Pixel C",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Google Pixel",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.1; Pixel Build/NDE63V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.85 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Google",
|
||||
"model": "Pixel",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Google Pixel",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.1; Pixel XL Build/NDE63X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.85 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Google",
|
||||
"model": "Pixel XL",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"desc": "Generic Android Device",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 6.0.1; i980 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Generic",
|
||||
"model": "Android 6.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "LG VK Series Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0.2; VK700 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.84 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "LG",
|
||||
"model": "VK700",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "LG LK Series Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0.1; LGLK430 Build/LRX21Y) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/38.0.2125.102 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "LG",
|
||||
"model": "LK430",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "RCA Voyager III Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; RCT6973W43 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "RCA",
|
||||
"model": "RCT6973W43",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "RCA Voyager II Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; RCT6773W22B Build/LRX21M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "RCA",
|
||||
"model": "RCT6773W22B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Verizon Quanta Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; QMV7B Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Verizon",
|
||||
"model": "QMV7B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Verizon Ellipsis 8 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; QTAQZ3 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Verizon",
|
||||
"model": "QTAQZ3",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Verizon Ellipsis 8HD Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; QTASUN1 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Verizon",
|
||||
"model": "QTASUN1",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Dell Venue 8 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Venue 8 3830 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Dell",
|
||||
"model": "Venue 8 3830",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Dell Venue 7 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Venue 7 3730 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Dell",
|
||||
"model": "Venue 7 3730",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Barnes & Noble Nook HD+ Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; Barnes & Noble Nook HD+ Build/JZO54K; CyanogenMod-10) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Barnes & Noble",
|
||||
"model": "Nook HD+",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Barnes & Noble V400 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.0.4; BNTV400 Build/IMM76L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.111 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Barnes & Noble",
|
||||
"model": "V400",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "NuVision TM101A540N Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1; TM101A540N Build/LMY47I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/50.0.2661.86 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "NuVision",
|
||||
"model": "TM101A540N",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE K Series Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; K88 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "K88",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Swizz GEN610",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; GEN610 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Swiss",
|
||||
"model": "GEN610",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Swizz ZUR700",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; ZUR700 Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Swiss",
|
||||
"model": "ZUR700",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Zeki TB782b Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-US; TB782B Build/IMM76D) AppleWebKit/534.31 (KHTML, like Gecko) UCBrowser/9.0.2.299 U3/0.8.0 Mobile Safari/534.31",
|
||||
"expect": {
|
||||
"vendor": "Zeki",
|
||||
"model": "TB782B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Dragon Touch Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.0.4; DT9138B Build/IMM76D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Dragon Touch",
|
||||
"model": "9138B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Insignia Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 6.0.1; NS-P08A7100 Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Insignia",
|
||||
"model": "NS-P08A7100",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Voice Xtreme V75",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.2.1; en-us; V75 Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Voice",
|
||||
"model": "V75",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "LvTel V11",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; V11 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "LvTel",
|
||||
"model": "V11",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Envizen Tablet V100MD",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; V100MD Build/V100MD.20130816) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Envizen",
|
||||
"model": "V100MD",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Rotor Tablet",
|
||||
"ua": "mozilla/5.0 (linux; android 5.0.1; tu_1491 build/lrx22c) applewebkit/537.36 (khtml, like gecko) chrome/43.0.2357.93 safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Rotor",
|
||||
"model": "1491",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "MachSpeed Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Trio 7.85 vQ Build/Trio_7.85_vQ) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "MachSpeed",
|
||||
"model": "Trio 7.85 vQ",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Trinity Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0.1; Trinity T101 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Trinity",
|
||||
"model": "T101",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "NextBook Next7",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; Next7P12 Build/IMM76I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "NextBook",
|
||||
"model": "Next7P12",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "NextBook Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; NXA8QC116 Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "NextBook",
|
||||
"model": "NXA8QC116",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Le Pan Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Le Pan TC802A Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Le Pan",
|
||||
"model": "TC802A",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Le Pan Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Le Pan TC802A Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Le Pan",
|
||||
"model": "TC802A",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Amazon Kindle Fire Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.4.3; en-us; KFSAWI Build/KTU84M) AppleWebKit/537.36 (KHTML, like Gecko) Silk/3.66 like Chrome/39.0.2171.93 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Amazon",
|
||||
"model": "KFSAWI",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Gigaset Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Gigaset QV830 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Gigaset",
|
||||
"model": "QV830",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Redmi Note 3",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; Redmi Note 3 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.116 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "Redmi Note 3",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "MI PAD 2",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1; MI PAD 2 Build/LMY47I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Safari/537.36 [FB_IAB/FB4A;FBAV/137.0.0.24.91;]",
|
||||
"expect": {
|
||||
"vendor": "Xiaomi",
|
||||
"model": "MI PAD 2",
|
||||
"type": "tablet"
|
||||
}
|
||||
}
|
||||
]
|
||||
42
test/dts-test.ts
Normal file
42
test/dts-test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { expectType } from 'tsd';
|
||||
import { UAParser, IResult, IBrowser, ICPU, IEngine, IDevice, IOS } from "../src/main/ua-parser";
|
||||
|
||||
const uastring = 'Mozilla/5.0 (X11; MyCustomOS; Linux i686; rv:19.0) Gecko/20100101 Firefox/19.0';
|
||||
const extensions = {
|
||||
os : [
|
||||
[/(mycustomos)/], [UAParser.OS.NAME, [UAParser.OS.VERSION, '10']]
|
||||
]
|
||||
};
|
||||
const headers = {
|
||||
'sec-ch-ua-mobile' : '?1'
|
||||
};
|
||||
|
||||
expectType<IResult>(UAParser());
|
||||
expectType<IResult>(UAParser(uastring));
|
||||
expectType<IResult>(UAParser(uastring, extensions));
|
||||
expectType<IResult>(UAParser(uastring, headers));
|
||||
expectType<IResult>(UAParser(extensions, headers));
|
||||
expectType<IResult>(UAParser(extensions));
|
||||
expectType<IResult>(UAParser(headers));
|
||||
expectType<UAParser>(new UAParser());
|
||||
|
||||
const parser = new UAParser(uastring);
|
||||
const browser = parser.getBrowser();
|
||||
|
||||
expectType<IBrowser>(browser);
|
||||
expectType<string | undefined>(browser.name);
|
||||
expectType<string | undefined>(browser.version);
|
||||
expectType<string | undefined>(browser.major);
|
||||
expectType<boolean>(browser.is(''));
|
||||
expectType<string>(browser.toString());
|
||||
expectType<IBrowser | PromiseLike<IBrowser>>(browser.withClientHints());
|
||||
expectType<IBrowser>((<IBrowser>browser.withClientHints()).withFeatureCheck());
|
||||
expectType<boolean>((<IBrowser>browser.withClientHints()).withFeatureCheck().is(''));
|
||||
|
||||
expectType<ICPU>(parser.getCPU());
|
||||
expectType<IDevice>(parser.getDevice());
|
||||
expectType<IEngine>(parser.getEngine());
|
||||
expectType<IOS>(parser.getOS());
|
||||
expectType<IResult>(parser.getResult());
|
||||
expectType<string>(parser.getUA());
|
||||
expectType<UAParser>(parser.setUA(uastring));
|
||||
@@ -1,74 +0,0 @@
|
||||
[
|
||||
{
|
||||
"desc" : "EdgeHTML",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Edge/12.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "EdgeHTML",
|
||||
"version" : "12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Gecko",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20110111 Firefox/4.0b9pre",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Gecko",
|
||||
"version" : "2.0b9pre"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "KHTML",
|
||||
"ua" : "Mozilla/5.0 (compatible; Konqueror/4.5; FreeBSD) KHTML/4.5.4 (like Gecko)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "KHTML",
|
||||
"version" : "4.5.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NetFront",
|
||||
"ua" : "Mozilla/4.0 (PDA; Windows CE/1.0.1) NetFront/3.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NetFront",
|
||||
"version" : "3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Presto",
|
||||
"ua" : "Opera/9.80 (Windows NT 6.1; Opera Tablet/15165; U; en) Presto/2.8.149 Version/11.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Presto",
|
||||
"version" : "2.8.149"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Tasman",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 6.0; PPC Mac OS X 10.4.7; Tasman 1.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Tasman",
|
||||
"version" : "1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Trident",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Trident",
|
||||
"version" : "6.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebKit",
|
||||
"ua" : "Mozilla/5.0 (Windows; U; Windows NT 6.1; sv-SE) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "533.19.4"
|
||||
}
|
||||
}
|
||||
]
|
||||
20
test/jazzer-fuzz-test.js
Normal file
20
test/jazzer-fuzz-test.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { FuzzedDataProvider } = require('@jazzer.js/core');
|
||||
const UAParser = require('ua-parser-js');
|
||||
const UA_MAX_LENGTH = 350;
|
||||
|
||||
module.exports.fuzz = function (buffer) {
|
||||
const data = new FuzzedDataProvider(buffer);
|
||||
const userAgent = data.consumeString(UA_MAX_LENGTH, 'utf-8', true);
|
||||
const start = process.hrtime();
|
||||
|
||||
UAParser(userAgent);
|
||||
|
||||
const elapsed = process.hrtime(start);
|
||||
const milisec = (elapsed[0]*1e3+elapsed[1]*1e-6).toFixed(3);
|
||||
if (milisec > 1000) {
|
||||
throw new Error(
|
||||
`Potential ReDoS\n` +
|
||||
`Time taken: ${milisec} ms.\n` +
|
||||
`User agent: ${userAgent}`);
|
||||
}
|
||||
};
|
||||
27
test/mocha-test-es6.mjs
Normal file
27
test/mocha-test-es6.mjs
Normal file
@@ -0,0 +1,27 @@
|
||||
import { UAParser } from '../src/main/ua-parser.mjs';
|
||||
import { CPU, Device, Engine } from '../src/enums/ua-parser-enums.mjs';
|
||||
import * as assert from 'assert';
|
||||
|
||||
describe('Returns', () => {
|
||||
it('getResult() should returns object', () => {
|
||||
assert.deepEqual(new UAParser('').getResult(),
|
||||
{
|
||||
ua : '',
|
||||
//ua_ch : { architecture: undefined, bitness: undefined, brands: undefined, fullVersionList: undefined, mobile: false, model: undefined, platform: undefined, platformVersion: undefined },
|
||||
browser: { name: undefined, version: undefined, major: undefined },
|
||||
cpu: { architecture: undefined },
|
||||
device: { vendor: undefined, model: undefined, type: undefined },
|
||||
engine: { name: undefined, version: undefined},
|
||||
os: { name: undefined, version: undefined }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Enums', () => {
|
||||
it('Can use enum', () => {
|
||||
const { cpu, device, engine } = UAParser('Mozilla/5.0 (X11; U; Linux armv7l; en-GB; rv:1.9.2a1pre) Gecko/20090928 Firefox/3.5 Maemo Browser 1.4.1.22 RX-51 N900');
|
||||
assert.strictEqual(cpu.is(CPU.ARM), true);
|
||||
assert.strictEqual(device.is(Device.MOBILE), true);
|
||||
assert.strictEqual(engine.is(Engine.GECKO), true);
|
||||
});
|
||||
});
|
||||
79
test/mocha-test-extension.js
Normal file
79
test/mocha-test-extension.js
Normal file
@@ -0,0 +1,79 @@
|
||||
const fs = require('fs');
|
||||
const assert = require('assert');
|
||||
const parseJS = require('@babel/parser').parse;
|
||||
const traverse = require('@babel/traverse').default;
|
||||
const safe = require('safe-regex');
|
||||
const UAParser = require('../src/main/ua-parser');
|
||||
const { Bots, CLIs, Emails, Modules } = require('../src/extensions/ua-parser-extensions');
|
||||
|
||||
describe('Bots', () => {
|
||||
it('Can detect bots', () => {
|
||||
const googleBot = 'Googlebot-Video/1.0';
|
||||
const gptBot = 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.0; +https://openai.com/gptbot)';
|
||||
const msnBot = 'msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)';
|
||||
const bingPreview = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534+ (KHTML, like Gecko) BingPreview/1.0b';
|
||||
const opera = 'Opera/8.5 (Macintosh; PPC Mac OS X; U; en)';
|
||||
const wget = 'Wget/1.21.1';
|
||||
const facebookBot = 'Mozilla/5.0 (compatible; FacebookBot/1.0; +https://developers.facebook.com/docs/sharing/webmasters/facebookbot/)';
|
||||
const outlook = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; Microsoft Outlook 16.0.9126; Microsoft Outlook 16.0.9126; ms-office; MSOffice 16)';
|
||||
const thunderbird = 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0';
|
||||
const axios = 'axios/1.3.5';
|
||||
const jsdom = 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/20.0.3';
|
||||
const scrapy = 'Scrapy/1.5.0 (+https://scrapy.org)';
|
||||
|
||||
const botParser = new UAParser(Bots);
|
||||
assert.deepEqual(botParser.setUA(googleBot).getBrowser(), {name: "Googlebot-Video", version: "1.0", major: "1", type: "bot"});
|
||||
assert.deepEqual(botParser.setUA(gptBot).getBrowser(), {name: "GPTBot", version: "1.0", major: "1", type: "bot"});
|
||||
assert.deepEqual(botParser.setUA(msnBot).getBrowser(), {name: "msnbot-media", version: "1.1", major: "1", type: "bot"});
|
||||
assert.deepEqual(botParser.setUA(bingPreview).getBrowser(), {name: "BingPreview", version: "1.0b", major: "1", type: "bot"});
|
||||
assert.deepEqual(botParser.setUA(opera).getBrowser(), {name: "Opera", version: "8.5", major: "8"});
|
||||
|
||||
// try merging Bots & CLIs
|
||||
const botsAndCLIs = { browser : [...Bots.browser, ...CLIs.browser]};
|
||||
const botsAndCLIsParser = new UAParser(botsAndCLIs);
|
||||
assert.deepEqual(botsAndCLIsParser.setUA(wget).getBrowser(), {name: "Wget", version: "1.21.1", major: "1", type:"cli"});
|
||||
assert.deepEqual(botsAndCLIsParser.setUA(facebookBot).getBrowser(), {name: "FacebookBot", version: "1.0", major: "1", type:"bot"});
|
||||
|
||||
const emailParser = new UAParser(Emails);
|
||||
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: "Microsoft Outlook", version: "16.0.9126", major: "16", type: "email"});
|
||||
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
|
||||
|
||||
const moduleParser = new UAParser(Modules);
|
||||
assert.deepEqual(moduleParser.setUA(axios).getBrowser(), {name: "axios", version: "1.3.5", major: "1", type: "module"});
|
||||
assert.deepEqual(moduleParser.setUA(jsdom).getBrowser(), {name: "jsdom", version: "20.0.3", major: "20", type: "module"});
|
||||
assert.deepEqual(moduleParser.setUA(scrapy).getBrowser(), {name: "Scrapy", version: "1.5.0", major: "1", type: "module"});
|
||||
});
|
||||
});
|
||||
|
||||
// TODO : move test spec to JSON file
|
||||
|
||||
describe('Testing regexes', () => {
|
||||
|
||||
let regexes;
|
||||
|
||||
before('Read main js file', () => {
|
||||
let code = fs.readFileSync('src/extensions/ua-parser-extensions.js', 'utf8').toString();
|
||||
let ast = parseJS(code, { sourceType: 'script' });
|
||||
regexes = [];
|
||||
traverse(ast, {
|
||||
RegExpLiteral: (path) => {
|
||||
regexes.push(path.node.pattern);
|
||||
}
|
||||
});
|
||||
if (regexes.length === 0) {
|
||||
throw new Error('Regexes cannot be empty!');
|
||||
}
|
||||
});
|
||||
|
||||
describe('Begin testing', () => {
|
||||
it('all regexes in extension file', () => {
|
||||
regexes.forEach(regex => {
|
||||
describe('Test against `safe-regex` : ' + regex, () => {
|
||||
it('should be safe from potentially vulnerable regex', () => {
|
||||
assert.strictEqual(safe(regex), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
493
test/mocha-test.js
Normal file
493
test/mocha-test.js
Normal file
File diff suppressed because one or more lines are too long
@@ -1,641 +0,0 @@
|
||||
[
|
||||
{
|
||||
"desc" : "Windows 95",
|
||||
"ua" : "Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "95"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows 98",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "98"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows ME",
|
||||
"ua" : "Mozilla/5.0 (Windows; U; Win 9x 4.90) Gecko/20020502 CS 2000 7.0/7.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "ME"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows 2000",
|
||||
"ua" : "Mozilla/3.0 (compatible; MSIE 3.0; Windows NT 5.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "2000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows XP",
|
||||
"ua" : "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 5.2)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "XP"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows Vista",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 6.0; fr-FR)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "Vista"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows 7",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows 8",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Win64; x64; Trident/6.0; .NET4.0E; .NET4.0C)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows 10",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "10"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows RT",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "RT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows CE",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.11)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "CE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows Mobile",
|
||||
"ua" : "Mozilla/5.0 (ZTE-E_N72/N72V1.0.0B02;U;Windows Mobile/6.1;Profile/MIDP-2.0 Configuration/CLDC-1.1;320*240;CTC/2.0) IE/6.0 (compatible; MSIE 4.01; Windows CE; PPC)/UC Browser7.7.1.88",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows Mobile",
|
||||
"version" : "6.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows Phone",
|
||||
"ua" : "Opera/9.80 (Windows Phone; Opera Mini/7.6.8/35.7518; U; ru) Presto/2.8.119 Version/11.10",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows Phone",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows Phone OS",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; DELL; Venue Pro)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows Phone OS",
|
||||
"version" : "7.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows Phone 8",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; HTC; Windows Phone 8X by HTC)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows Phone",
|
||||
"version" : "8.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BlackBerry",
|
||||
"ua" : "BlackBerry9300/5.0.0.912 Profile/MIDP-2.1 Configuration/CLDC-1.1 VendorID/378",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BlackBerry",
|
||||
"version" : "5.0.0.912"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BlackBerry 10",
|
||||
"ua" : "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.3+ (KHTML, like Gecko) Version/10.0.9.386 Mobile Safari/537.3+",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BlackBerry",
|
||||
"version" : "10"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Tizen",
|
||||
"ua" : "Mozilla/5.0 (Linux; Tizen 2.3; SAMSUNG SM-Z130H) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.3 Mobile Safari/537.3",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Tizen",
|
||||
"version" : "2.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Android",
|
||||
"ua" : "Mozilla/5.0 (Linux; U; Android 2.2.2; en-us; VM670 Build/FRG83G) AppleWebKit/533.1 (KHTML, like Gecko)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Android",
|
||||
"version" : "2.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Palm OS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "QNX",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Bada",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RIM Tablet OS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MeeGo",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Symbian",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Firefox OS",
|
||||
"ua" : "Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Firefox OS",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Nintendo",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "PlayStation",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "PlayStation 4",
|
||||
"ua" : "Mozilla/5.0 (PlayStation 4 3.00) AppleWebKit/537.73 (KHTML, like Gecko)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "PlayStation",
|
||||
"version" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mint",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Joli",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Ubuntu",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.22+ (KHTML, like Gecko) Chromium/17.0.963.56 Chrome/17.0.963.56 Safari/535.22+ Ubuntu/12.04 (3.4.1-0ubuntu1) Epiphany/3.4.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Ubuntu",
|
||||
"version" : "12.04"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Ubuntu",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/31.0.1650.63 Chrome/31.0.1650.63 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Ubuntu",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Debian",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "OpenSUSE",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Gentoo",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Arch",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Slackware",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Fedora",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mandriva",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "CentOS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "PCLinuxOS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RedHat",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Zenwalk",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Hurd",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Linux",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "GNU",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Chromium OS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Solaris",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "FreeBSD",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "OpenBSD",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NetBSD",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "DragonFly",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "iOS in App",
|
||||
"ua" : "AppName/version CFNetwork/version Darwin/version",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "iOS",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "iOS with Chrome",
|
||||
"ua" : "Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "iOS",
|
||||
"version" : "5.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "iOS with Opera Mini",
|
||||
"ua" : "Opera/9.80 (iPhone; Opera Mini/7.1.32694/27.1407; U; en) Presto/2.8.119 Version/11.10",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "iOS",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac OS",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Mac OS",
|
||||
"version" : "10.6.8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Haiku",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Haiku R1 x86) AppleWebKit/602.1.1 (KHTML, like Gecko) WebPositive/1.2 Version/8.0 Safari/602.1.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Haiku",
|
||||
"version" : "R1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AIX",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Plan9",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Minix",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BeOS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "OS/2",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AmigaOS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MorphOS",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "UNIX",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "iTunes Windows Vista",
|
||||
"ua" : "iTunes/10.7 (Windows; Microsoft Windows Vista Home Premium Edition Service Pack 1 (Build 6001)) AppleWebKit/536.26.9",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows",
|
||||
"version" : "Vista"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "",
|
||||
"ua" : "",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "iOS BE App",
|
||||
"ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "iOS",
|
||||
"version" : "7.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "KTB-Nexus 5",
|
||||
"ua" : "APP-My App/1.0 (Linux; Android 4.2.1; Nexus 5 Build/JOP40D)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Android",
|
||||
"version" : "4.2.1"
|
||||
}
|
||||
}
|
||||
]
|
||||
79
test/playwright-test-main.spec.mjs
Normal file
79
test/playwright-test-main.spec.mjs
Normal file
@@ -0,0 +1,79 @@
|
||||
// @ts-check
|
||||
import { test, expect } from '@playwright/test';
|
||||
import path from 'path';
|
||||
import url from 'url';
|
||||
|
||||
const localHtml = `file://${path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '../')}/dist/ua-parser.html`;
|
||||
|
||||
test.describe('test input', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(localHtml);
|
||||
});
|
||||
|
||||
test('accept empty string', async ({ page }) => {
|
||||
// @ts-ignore
|
||||
const uap = await page.evaluate(async () => await UAParser(''));
|
||||
expect(uap).toHaveProperty('ua', '');
|
||||
});
|
||||
});
|
||||
|
||||
test('read client hints data', async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
Object.defineProperty(navigator, 'userAgentData', {
|
||||
value: {
|
||||
brands: [],
|
||||
platform: '',
|
||||
mobile: false,
|
||||
getHighEntropyValues: () => {
|
||||
return Promise.resolve({
|
||||
brands: [
|
||||
{
|
||||
brand: 'Chromium',
|
||||
version: '110'
|
||||
},
|
||||
{
|
||||
brand: 'Not(A:Brand',
|
||||
version: '110'
|
||||
},
|
||||
{
|
||||
brand: 'New Browser',
|
||||
version: '110'
|
||||
}
|
||||
],
|
||||
platform: 'New OS',
|
||||
formFactor: 'New Form Factor'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto(localHtml);
|
||||
|
||||
// @ts-ignore
|
||||
const uap = await page.evaluate(async () => await UAParser().withClientHints());
|
||||
|
||||
expect(uap).toHaveProperty('browser.name', 'New Browser');
|
||||
expect(uap).toHaveProperty('os.name', 'New OS');
|
||||
expect(uap).toHaveProperty('device.type', undefined);
|
||||
});
|
||||
|
||||
test('detect Brave', async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
Object.defineProperty(navigator, 'brave', {
|
||||
value: {
|
||||
isBrave: () => true
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto(localHtml);
|
||||
|
||||
// @ts-ignore
|
||||
let uap = await page.evaluate(() => UAParser());
|
||||
expect(uap).toHaveProperty('browser.name', 'Chrome Headless');
|
||||
|
||||
// @ts-ignore
|
||||
uap = await page.evaluate(() => UAParser().withFeatureCheck());
|
||||
expect(uap).toHaveProperty('browser.name', 'Brave');
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
266
test/specs/cpu-all.json
Normal file
266
test/specs/cpu-all.json
Normal file
@@ -0,0 +1,266 @@
|
||||
[
|
||||
{
|
||||
"desc" : "i686",
|
||||
"ua" : "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:19.0) Gecko/20100101 Firefox/19.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "i386",
|
||||
"ua" : "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040628 Epiphany/1.2.6",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "x86-64",
|
||||
"ua" : "Opera/9.80 (X11; Linux x86_64; U; Linux Mint; en) Presto/2.2.15 Version/10.10",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Windows",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Windows",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Linux",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Linux",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi POCO M2 Pro",
|
||||
"ua": "Mozilla/5.0 (Linux; arm_64; Android 11; POCO M2 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 YaBrowser/22.11.7.42.00 SA/3 Mobile Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "win64",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Win64; x64; Trident/6.0; .NET4.0E; .NET4.0C)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WOW64",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARM",
|
||||
"ua" : "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 635) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv61",
|
||||
"ua" : "Mozilla/5.0 (X11; U; Linux armv61; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv7",
|
||||
"ua" : "Mozilla/5.0 (Linux ARMv7) WebKitGTK+/3.4.9 vimprobable2",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv7l",
|
||||
"ua" : "Mozilla/5.0 (SMART-TV; X11; Linux armv7l) AppleWebKit/537.42 (KHTML, like Gecko) Chromium/25.0.1349.2 Chrome/25.0.1349.2 Safari/537.42",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv7l",
|
||||
"ua" : "Mozilla/5.0 (X11; CrOS armv7l 9765.85.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.123 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Nokia N900 Linux mobile",
|
||||
"ua" : "Mozilla/5.0 (Maemo; Linux armv7l; rv:10.0) Gecko/20100101 Firefox/10.0 Fennec/10.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMEABI",
|
||||
"ua" : "[FBAN/FB4A;FBAV/237.0.0.44.120;FBBV/170693408;FBDM/{density=1.75,width=720,height=1280};FBLC/en_US;FBRV/172067074;FBCR/ ;FBMF/samsung;FBBD/samsung;FBPN/com.facebook.katana;FBDV/SM-S367VL;FBSV/9;FBBK/1;FBOP/19;FBCA/armeabi-v7a:armeabi;]",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv8",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux armv8l; rv:45.0) Gecko/20100101 Firefox/45.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AARCH64",
|
||||
"ua" : "Mozilla/5.0 (X11; CrOS aarch64 13310.93.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.133 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARM64",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; ARM64; RM-1096) AppleWebKit/537.36 (KHTML like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARM64",
|
||||
"ua" : "Mozilla/5.0 (Linux; arm_64; Android 9; HRY-LX1T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 YaBrowser/19.12.1.121.00 Mobile Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Google Search App",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 6.0; M5s Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.147 Mobile Safari/537.36 GSA/12.40.17.23.arm64",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Pocket PC",
|
||||
"ua" : "Opera/9.7 (Windows Mobile; PPC; Opera Mobi/35166; U; en) Presto/2.2.1",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 5.17; Mac_PowerPC Mac OS; en)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "iCab/2.9.5 (Macintosh; U; PPC; Mac OS X)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac OS X on PowerPC using Firefox",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; PPC Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "UltraSPARC",
|
||||
"ua" : "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "sparc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "sparc64",
|
||||
"ua" : "ELinks (0.4.3; NetBSD 3.0.2PATCH sparc64; 141x19)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "sparc64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "QuickTime",
|
||||
"ua" : "QuickTime/7.5.6 (qtver=7.5.6;cpu=IA32;os=Mac 10.5.8)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "XBMC",
|
||||
"ua" : "XBMC/12.0 Git:20130127-fb595f2 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "IRIX64",
|
||||
"ua" : "Mozilla/4.8C-SGI [en] (X11; U; IRIX64 6.5 IP27",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "irix64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "68k",
|
||||
"ua" : "'Mozilla/1.1 (Macintosh; U; 68K)'",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "68k"
|
||||
}
|
||||
}
|
||||
]
|
||||
3553
test/specs/device-all.json
Normal file
3553
test/specs/device-all.json
Normal file
File diff suppressed because it is too large
Load Diff
164
test/specs/engine-all.json
Normal file
164
test/specs/engine-all.json
Normal file
@@ -0,0 +1,164 @@
|
||||
[
|
||||
{
|
||||
"desc" : "Blink",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 7.0; SM-G920I Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/3.4.9 SamsungBrowser/4.0 Chrome/57.0.2987.146 Mobile VR Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "57.0.2987.146"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "EdgeHTML",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Edge/12.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "EdgeHTML",
|
||||
"version" : "12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Flow",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) EkiohFlow/5.7.4.30559 Flow/5.7.4 (like Gecko Firefox/53.0 rv:53.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Flow",
|
||||
"version" : "5.7.4.30559"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Gecko",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20110111 Firefox/4.0b9pre",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Gecko",
|
||||
"version" : "2.0b9pre"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Goanna",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 5.1; rv:38.9) Gecko/20100101 Goanna/2.2 Firefox/38.9 PaleMoon/26.5.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Goanna",
|
||||
"version" : "2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "KHTML",
|
||||
"ua" : "Mozilla/5.0 (compatible; Konqueror/4.5; FreeBSD) KHTML/4.5.4 (like Gecko)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "KHTML",
|
||||
"version" : "4.5.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LibWeb",
|
||||
"ua" : "Mozilla/4.0 (SerenityOS; x86) LibWeb+LibJS (Not KHTML, nor Gecko) LibWeb",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LibWeb",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NetFront",
|
||||
"ua" : "Mozilla/4.0 (PDA; Windows CE/1.0.1) NetFront/3.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NetFront",
|
||||
"version" : "3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Presto",
|
||||
"ua" : "Opera/9.80 (Windows NT 6.1; Opera Tablet/15165; U; en) Presto/2.8.149 Version/11.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Presto",
|
||||
"version" : "2.8.149"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Tasman",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 6.0; PPC Mac OS X 10.4.7; Tasman 1.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Tasman",
|
||||
"version" : "1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Trident",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Trident",
|
||||
"version" : "6.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebKit",
|
||||
"ua" : "Mozilla/5.0 (Windows; U; Windows NT 6.1; sv-SE) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "533.19.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebKit",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/27.0.1453.110 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "537.36"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 5.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 WebAppManager",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "68.0.3440.106"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 4.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.34 Safari/537.36 WebAppManager",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "53.0.2785.34"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 3.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.2.1 Chrome/38.0.2125.122 Safari/537.36 WebAppManager",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "38.0.2125.122"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 2.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen WebAppManager Safari/538.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "538.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 1.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.41 (KHTML, like Gecko) Large Screen WebAppManager Safari/537.41",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "537.41"
|
||||
}
|
||||
}
|
||||
]
|
||||
342
test/specs/extension-device.json
Normal file
342
test/specs/extension-device.json
Normal file
@@ -0,0 +1,342 @@
|
||||
[{
|
||||
"desc": "Essential PH-1",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 9; PH-1 Build/PPR1.180905.036) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.86 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Essential",
|
||||
"model": "PH-1",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Gigaset Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Gigaset QV830 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Gigaset",
|
||||
"model": "QV830",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "RCA Voyager III Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; RCT6973W43 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "RCA",
|
||||
"model": "RCT6973W43",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "RCA Voyager II Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; RCT6773W22B Build/LRX21M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "RCA",
|
||||
"model": "RCT6773W22B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Verizon Quanta Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; QMV7B Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Verizon",
|
||||
"model": "QMV7B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Verizon Ellipsis 8 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; QTAQZ3 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Verizon",
|
||||
"model": "QTAQZ3",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Verizon Ellipsis 8HD Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; QTASUN1 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Verizon",
|
||||
"model": "QTASUN1",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Dell Venue 8 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Venue 8 3830 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Dell",
|
||||
"model": "Venue 8 3830",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Dell Venue 7 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Venue 7 3730 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Dell",
|
||||
"model": "Venue 7 3730",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Barnes & Noble Nook HD+ Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; Barnes & Noble Nook HD+ Build/JZO54K; CyanogenMod-10) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Barnes & Noble",
|
||||
"model": "Nook HD+",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Barnes & Noble V400 Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.0.4; BNTV400 Build/IMM76L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.111 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Barnes & Noble",
|
||||
"model": "V400",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "NuVision TM101A540N Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1; TM101A540N Build/LMY47I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/50.0.2661.86 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "NuVision",
|
||||
"model": "TM101A540N",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE-Z431",
|
||||
"ua": "ZTE-Z431/1.4.0 NetFront/4.2 QTV5.1 Profile/MIDP-2.1 Configuration/CLDC-1.1",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "Z431",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; ZTE-Z740G Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "Z740G",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE K Series Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; K88 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "K88",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE Nubia Red Magic 3",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 9; NX629J Build/PKQ1.190321.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/45016 Mobile Safari/537.36 MMWEBID/4064 MicroMessenger/7.0.10.1580(0x27000A34) Process/tools NetType/WIFI Language/zh_CN ABI/arm64",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "NX629J",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE Blade A5",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 9; ZTE Blade A5 2019) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.116 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "Blade A5 2019",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE BLADE V0730",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 6.0; ZTE BLADE V0730) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.116 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "BLADE V0730",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "ZTE B2017G",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 7.1.1; ZTE B2017G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "ZTE",
|
||||
"model": "B2017G",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Swizz GEN610",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; GEN610 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Swiss",
|
||||
"model": "GEN610",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Swizz ZUR700",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; ZUR700 Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Swiss",
|
||||
"model": "ZUR700",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Zeki TB782b Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-US; TB782B Build/IMM76D) AppleWebKit/534.31 (KHTML, like Gecko) UCBrowser/9.0.2.299 U3/0.8.0 Mobile Safari/534.31",
|
||||
"expect": {
|
||||
"vendor": "Zeki",
|
||||
"model": "TB782B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Dragon Touch Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.0.4; DT9138B Build/IMM76D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Dragon Touch",
|
||||
"model": "9138B",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Insignia Tablet",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 6.0.1; NS-P08A7100 Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Insignia",
|
||||
"model": "NS-P08A7100",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Voice Xtreme V75",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.2.1; en-us; V75 Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Voice",
|
||||
"model": "V75",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "LvTel V11",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; V11 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "LvTel",
|
||||
"model": "V11",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Envizen Tablet V100MD",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; V100MD Build/V100MD.20130816) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "Envizen",
|
||||
"model": "V100MD",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Rotor Tablet",
|
||||
"ua": "mozilla/5.0 (linux; android 5.0.1; tu_1491 build/lrx22c) applewebkit/537.36 (khtml, like gecko) chrome/43.0.2357.93 safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Rotor",
|
||||
"model": "1491",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "MachSpeed Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Trio 7.85 vQ Build/Trio_7.85_vQ) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "MachSpeed",
|
||||
"model": "Trio 7.85 vQ",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Trinity Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0.1; Trinity T101 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Trinity",
|
||||
"model": "T101",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "NextBook Next7",
|
||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; Next7P12 Build/IMM76I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
||||
"expect": {
|
||||
"vendor": "NextBook",
|
||||
"model": "Next7P12",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "NextBook Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; NXA8QC116 Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "NextBook",
|
||||
"model": "NXA8QC116",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Le Pan Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Le Pan TC802A Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Le Pan",
|
||||
"model": "TC802A",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Le Pan Tablets",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Le Pan TC802A Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Le Pan",
|
||||
"model": "TC802A",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "AT&T Radiant Core U304AA",
|
||||
"ua": "Dalvik/2.1.0 (Linux; U; Android 9; U304AA Build/P00610)",
|
||||
"expect": {
|
||||
"vendor": "AT&T",
|
||||
"model": "U304AA",
|
||||
"type": "mobile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Vodafone Smart Tab 4G",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.4; Vodafone Smart Tab 4G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Vodafone",
|
||||
"model": "Smart Tab 4G",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Vodafone Smart ultra 6",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 5.0.2; Vodafone Smart ultra 6 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.133 Mobile Safari/537.36",
|
||||
"expect": {
|
||||
"vendor": "Vodafone",
|
||||
"model": "Smart ultra 6",
|
||||
"type": "tablet"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "4ife 4K Smart TV Box",
|
||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; 4ife 4K Smart TV Box Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36 Vinebre",
|
||||
"expect": {
|
||||
"vendor": "undefined",
|
||||
"model": "undefined",
|
||||
"type": "smarttv"
|
||||
}
|
||||
}]
|
||||
1226
test/specs/os-all.json
Normal file
1226
test/specs/os-all.json
Normal file
File diff suppressed because it is too large
Load Diff
113
test/test.js
113
test/test.js
@@ -1,113 +0,0 @@
|
||||
var assert = require('assert');
|
||||
var requirejs = require('requirejs');
|
||||
var UAParser = require('./../src/ua-parser');
|
||||
var browsers = require('./browser-test.json');
|
||||
var cpus = require('./cpu-test.json');
|
||||
var devices = require('./device-test.json');
|
||||
var engines = require('./engine-test.json');
|
||||
var os = require('./os-test.json');
|
||||
var parser = new UAParser();
|
||||
var methods = [
|
||||
{
|
||||
title : 'getBrowser',
|
||||
label : 'browser',
|
||||
list : browsers,
|
||||
properties : ['name', 'major', 'version']
|
||||
},
|
||||
{
|
||||
title : 'getCPU',
|
||||
label : 'cpu',
|
||||
list : cpus,
|
||||
properties : ['architecture']
|
||||
},
|
||||
{
|
||||
title : 'getDevice',
|
||||
label : 'device',
|
||||
list : devices,
|
||||
properties : ['model', 'type', 'vendor']
|
||||
},
|
||||
{
|
||||
title : 'getEngine',
|
||||
label : 'engine',
|
||||
list : engines,
|
||||
properties : ['name', 'version']
|
||||
},
|
||||
{
|
||||
title : 'getOS',
|
||||
label : 'os',
|
||||
list : os,
|
||||
properties : ['name', 'version']
|
||||
}];
|
||||
|
||||
describe('UAParser()', function () {
|
||||
var ua = 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6';
|
||||
assert.deepEqual(UAParser(ua), new UAParser().setUA(ua).getResult());
|
||||
});
|
||||
|
||||
for (var i in methods) {
|
||||
describe(methods[i]['title'], function () {
|
||||
for (var j in methods[i]['list']) {
|
||||
if (!!methods[i]['list'][j].ua) {
|
||||
describe('[' + methods[i]['list'][j].desc + ']', function () {
|
||||
describe('"' + methods[i]['list'][j].ua + '"', function () {
|
||||
var expect = methods[i]['list'][j].expect;
|
||||
var result = parser.setUA(methods[i]['list'][j].ua).getResult()[methods[i]['label']];
|
||||
|
||||
methods[i]['properties'].forEach(function(m) {
|
||||
it('should return ' + methods[i]['label'] + ' ' + m + ': ' + expect[m], function () {
|
||||
assert.equal(result[m], expect[m] != 'undefined' ? expect[m] : undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe('Returns', function () {
|
||||
it('getResult() should returns JSON', function(done) {
|
||||
assert.deepEqual(new UAParser('').getResult(),
|
||||
{
|
||||
ua : '',
|
||||
browser: { name: undefined, version: undefined, major: undefined },
|
||||
cpu: { architecture: undefined },
|
||||
device: { vendor: undefined, model: undefined, type: undefined },
|
||||
engine: { name: undefined, version: undefined},
|
||||
os: { name: undefined, version: undefined }
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Extending Regex', function () {
|
||||
var uaString = 'Mozilla/5.0 MyOwnBrowser/1.3';
|
||||
var myOwnBrowser = [[/(myownbrowser)\/((\d+)?[\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION, UAParser.BROWSER.MAJOR]];
|
||||
|
||||
var parser1 = new UAParser(uaString, {browser: myOwnBrowser});
|
||||
assert.equal(parser1.getBrowser().name, 'MyOwnBrowser');
|
||||
assert.equal(parser1.getBrowser().version, '1.3');
|
||||
assert.equal(parser1.getBrowser().major, '1');
|
||||
|
||||
var parser2 = new UAParser({browser: myOwnBrowser});
|
||||
assert.equal(parser2.getBrowser().name, undefined);
|
||||
parser2.setUA(uaString);
|
||||
assert.equal(parser2.getBrowser().name, 'MyOwnBrowser');
|
||||
assert.equal(parser1.getBrowser().version, '1.3');
|
||||
});
|
||||
|
||||
describe('Using Require.js', function () {
|
||||
it('should loaded automatically', function(done) {
|
||||
requirejs.config({
|
||||
baseUrl : 'dist',
|
||||
paths : {
|
||||
'ua-parser-js' : 'ua-parser.min'
|
||||
}
|
||||
});
|
||||
requirejs(['ua-parser-js'], function(ua) {
|
||||
var parser = new ua('Dillo/1.0');
|
||||
assert.deepEqual(parser.getBrowser().name, 'Dillo');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user