mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-15 22:52:16 +03:00
Compare commits
393 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a88934fadf | ||
|
|
8cf2a87938 | ||
|
|
b1d6eda6e1 | ||
|
|
a9fc6163b8 | ||
|
|
7ef62a68de | ||
|
|
de3b3bd55e | ||
|
|
700220f2b9 | ||
|
|
90ae87ec17 | ||
|
|
f60fdbefa5 | ||
|
|
97e919024b | ||
|
|
a88b70bdd4 | ||
|
|
89635fcc6e | ||
|
|
b6d2bb5262 | ||
|
|
73192e64d4 | ||
|
|
557c46f413 | ||
|
|
9fb502ea6d | ||
|
|
37cac21d0c | ||
|
|
95f37b4ce5 | ||
|
|
cc479f81ae | ||
|
|
d1a7f365ad | ||
|
|
a4da1e2b65 | ||
|
|
795139e1b8 | ||
|
|
97dc89ae03 | ||
|
|
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 | ||
|
|
34f934fa55 | ||
|
|
218e3a4a3b | ||
|
|
5eda2491b1 | ||
|
|
7acaf9ced8 | ||
|
|
bafac18512 | ||
|
|
ee553df245 | ||
|
|
bc4e75573a | ||
|
|
378dee1aaa | ||
|
|
d413cb0745 | ||
|
|
7fb860f030 | ||
|
|
2e57a9778f | ||
|
|
fb92a46479 | ||
|
|
4790f944bf | ||
|
|
3ed9d3f4ff | ||
|
|
0c6ae1a1e3 | ||
|
|
84bfaaf225 | ||
|
|
9ceb402834 | ||
|
|
a795cf83c4 | ||
|
|
8b54a7256e | ||
|
|
dfb8e758d1 | ||
|
|
083cb66d46 | ||
|
|
50bd78afb1 | ||
|
|
ac7f87f199 | ||
|
|
b367a3f741 | ||
|
|
4bbd7bd27c | ||
|
|
610781dac3 | ||
|
|
1b86f8fb94 | ||
|
|
0413755986 | ||
|
|
618c92aec9 | ||
|
|
7964f909a3 | ||
|
|
934e077aea | ||
|
|
503bb6eb06 | ||
|
|
435335e12f | ||
|
|
a6e1ed6392 | ||
|
|
9dfeee5211 | ||
|
|
ce2a8a3939 | ||
|
|
46dfe2aeb8 | ||
|
|
9c06febfce | ||
|
|
a75de42f8e | ||
|
|
6095258673 | ||
|
|
40aa1a693b | ||
|
|
25e143ee7c | ||
|
|
7bd9ffea24 | ||
|
|
c566f45cbd | ||
|
|
3b89dff771 | ||
|
|
5ba5e7abc9 | ||
|
|
b8978f5933 | ||
|
|
eeb1b9ef81 | ||
|
|
aeae29be66 | ||
|
|
3ce12c0cf9 | ||
|
|
4d95ac10ef | ||
|
|
61b4a089c5 | ||
|
|
74ec93ffb6 | ||
|
|
2c28b3e97e | ||
|
|
459f3d34f5 | ||
|
|
6f621f1ae2 | ||
|
|
7ae3098778 | ||
|
|
806c2b8030 | ||
|
|
cb1a64b509 | ||
|
|
b49cfae4e2 | ||
|
|
91b046462c | ||
|
|
69509af6dd | ||
|
|
225f703b67 | ||
|
|
7f217753f5 | ||
|
|
10f9fb35ca | ||
|
|
5ae468a3d3 | ||
|
|
fd46c4d2be | ||
|
|
297c6538bc | ||
|
|
f9f9fa79e1 | ||
|
|
07fe58b793 | ||
|
|
3a4626b5e8 | ||
|
|
3fd01f07ea | ||
|
|
d103dd5450 | ||
|
|
6cc6742f5e | ||
|
|
cf977c50ed | ||
|
|
4c15b10730 | ||
|
|
a3c7619d3a | ||
|
|
82aba654f9 | ||
|
|
2f1b14906f | ||
|
|
a3a09d33bc | ||
|
|
946ba02c54 | ||
|
|
d2d570fcd5 | ||
|
|
18e08428f4 | ||
|
|
552915907e | ||
|
|
6984de7927 | ||
|
|
7a68f35574 | ||
|
|
2bc75f10bc | ||
|
|
2610f37a8b | ||
|
|
a25bb8b1a6 | ||
|
|
ee2db31f8c | ||
|
|
89775a8ae7 | ||
|
|
7d826ed62e | ||
|
|
a6316f02b0 | ||
|
|
72a11e24b2 | ||
|
|
f7ca724f3b | ||
|
|
8d826fcc24 | ||
|
|
951106c425 | ||
|
|
83ca52bb28 | ||
|
|
6fb4941458 | ||
|
|
48ab3b372c | ||
|
|
38c409e8d9 | ||
|
|
4e2cbdfd16 | ||
|
|
fbe8a0e3a6 | ||
|
|
8e9c400ec5 | ||
|
|
b89fa098aa | ||
|
|
f3882f1882 | ||
|
|
a25426840c | ||
|
|
985a7b18e0 | ||
|
|
8e09cd49e3 | ||
|
|
4768992762 | ||
|
|
f89e08f2c0 | ||
|
|
fe568ffe96 | ||
|
|
252db2534e | ||
|
|
6555bf6e81 | ||
|
|
740fc93b4b | ||
|
|
eed646f9ce | ||
|
|
764de40fe0 | ||
|
|
49609c0990 | ||
|
|
ef69224d7c | ||
|
|
caa2f47c06 | ||
|
|
5177c460a5 | ||
|
|
3e2d5c1817 | ||
|
|
29a0372611 | ||
|
|
2aa2f77881 | ||
|
|
1e228b2fbe | ||
|
|
5379ec8513 | ||
|
|
01ae611dfa | ||
|
|
2de1f2a75d | ||
|
|
975cbdc89e | ||
|
|
507714c3c7 | ||
|
|
2b4a20d162 | ||
|
|
34848e8ec2 | ||
|
|
97b52b2cfd | ||
|
|
9f0419607b | ||
|
|
b13c891d7f | ||
|
|
7f9919f896 | ||
|
|
9fe7561d78 | ||
|
|
b99840d074 | ||
|
|
61b0f1c054 | ||
|
|
58880fda7f | ||
|
|
73735e1ca8 | ||
|
|
0f0ea13fab | ||
|
|
1fb82fb6ff | ||
|
|
88f2f4e24c | ||
|
|
1a4dab5829 | ||
|
|
2467a458e3 | ||
|
|
aadabcce29 | ||
|
|
d0b7c5892f | ||
|
|
d3f959ee28 | ||
|
|
d1a33d7d85 | ||
|
|
3dae55a3c8 | ||
|
|
87b88246a2 | ||
|
|
a56c990ec3 | ||
|
|
458f3c3cd2 | ||
|
|
f28f87c412 | ||
|
|
10775bd17c | ||
|
|
c03a84a601 | ||
|
|
eade7a9355 | ||
|
|
4e0aa0b88b | ||
|
|
4e7c662b0b | ||
|
|
93993dc311 | ||
|
|
55e75dd1b3 | ||
|
|
c71373b666 | ||
|
|
bf4c2e170e | ||
|
|
51b8089958 | ||
|
|
550420d725 | ||
|
|
fbcfe248b8 | ||
|
|
2a5cd4d119 | ||
|
|
c3f7294a44 | ||
|
|
b254f93ec1 | ||
|
|
1020d10a30 | ||
|
|
5ba9fd50ed | ||
|
|
bb69ef2bd4 | ||
|
|
3a457f9bd9 | ||
|
|
d929c3e508 | ||
|
|
0d42b3a752 | ||
|
|
1ec2119288 | ||
|
|
4344c43d04 | ||
|
|
909d6fc26d | ||
|
|
8e46a85549 | ||
|
|
1f92d6148c | ||
|
|
5d57850074 | ||
|
|
8e81811dea | ||
|
|
99a80e88fb | ||
|
|
cbba2f5728 | ||
|
|
fd39be3336 | ||
|
|
a1293f804e | ||
|
|
cf5c1f9e01 | ||
|
|
5d3835ad00 | ||
|
|
09bf4ecf7f | ||
|
|
43b0ee79d6 | ||
|
|
9518833e83 | ||
|
|
1e58e884ef | ||
|
|
e230cc1920 | ||
|
|
bbd3f14cfb | ||
|
|
a66d9b238a | ||
|
|
ae5bfb3893 | ||
|
|
2e5dff95c8 | ||
|
|
e944fededb | ||
|
|
23160c9fb3 | ||
|
|
01ba36c94d | ||
|
|
99c15dee95 | ||
|
|
e8bec7e611 | ||
|
|
f670224d8e | ||
|
|
116b5c695d | ||
|
|
0aafba67fa | ||
|
|
ab6a56d931 | ||
|
|
3bff4cf037 | ||
|
|
792dc0246a | ||
|
|
3964971c38 | ||
|
|
3382b75cad | ||
|
|
a19c6be712 | ||
|
|
20ea67ed1d | ||
|
|
172d63a28f | ||
|
|
992e829643 | ||
|
|
e9e5467add | ||
|
|
d3a2e1750b | ||
|
|
29d75c994e | ||
|
|
7e23d53e4b | ||
|
|
892476f544 | ||
|
|
a165e152de | ||
|
|
ab64c21a80 | ||
|
|
5da2305369 | ||
|
|
8e169098b5 | ||
|
|
aa1bf53337 | ||
|
|
1b957cad1a | ||
|
|
8d9cd21331 | ||
|
|
f117f600ba | ||
|
|
22e17fb004 | ||
|
|
978ee5a4da | ||
|
|
a3e4fbe5bb | ||
|
|
9dacf37e4a | ||
|
|
4d99bc0777 | ||
|
|
f558e657bb | ||
|
|
4203f8144f | ||
|
|
21a525f442 | ||
|
|
3abf465aec | ||
|
|
56c90d2134 | ||
|
|
dc6bae6aae | ||
|
|
1fa7137f1f | ||
|
|
378a298fee | ||
|
|
32db7bfb97 | ||
|
|
d1a18c6ff1 | ||
|
|
4887793ee0 | ||
|
|
b616d0b3d1 | ||
|
|
c7749b3a2a | ||
|
|
b00b2a7bcf | ||
|
|
ca4e8ce2e6 | ||
|
|
3d2d8d5d84 | ||
|
|
cce9dc1474 | ||
|
|
fa6f8de25f | ||
|
|
6a284e2670 | ||
|
|
ad2613d8e9 | ||
|
|
866bdc27af | ||
|
|
a5cb2d8821 | ||
|
|
fe133e4228 | ||
|
|
357ea1b42f | ||
|
|
89a3a21ce3 | ||
|
|
3c911f2dd4 | ||
|
|
69c688810d | ||
|
|
6b2571eaa3 | ||
|
|
5dcc4db665 | ||
|
|
af9fc69161 | ||
|
|
feed5498eb | ||
|
|
2e87b02dda | ||
|
|
f6b22d6654 | ||
|
|
354d29c2b6 | ||
|
|
6402ac67b9 | ||
|
|
7cae802f3c | ||
|
|
5c25229616 | ||
|
|
9d383c5395 | ||
|
|
1eeb1face1 | ||
|
|
c3ddbe27ae | ||
|
|
073b551b90 | ||
|
|
7d5e50f008 | ||
|
|
294fae589d | ||
|
|
d47e1a5e8e | ||
|
|
50c4e3e551 | ||
|
|
5002ea0846 | ||
|
|
bc4561b1c1 | ||
|
|
083db7b7d2 | ||
|
|
744c9bf0bd | ||
|
|
27c17736c2 | ||
|
|
4d3656bb9c | ||
|
|
551fbf100c | ||
|
|
e725633328 | ||
|
|
d5cf025713 | ||
|
|
9256ed4186 | ||
|
|
70d629ca71 | ||
|
|
0951cebd09 | ||
|
|
0a2b05c6fd | ||
|
|
9e81f03558 | ||
|
|
a04d2c0efc | ||
|
|
152377b390 | ||
|
|
d3f1b0eaf7 | ||
|
|
a78d3f7d4b | ||
|
|
b0ed222114 | ||
|
|
8c813e15b3 | ||
|
|
e6c2296d86 | ||
|
|
577ded5272 | ||
|
|
a455d7be0d | ||
|
|
4222c6c1e0 | ||
|
|
2be03bf30c | ||
|
|
6c1c202815 | ||
|
|
d3a0e23945 | ||
|
|
6bb2e23924 | ||
|
|
4e41b6e1d0 | ||
|
|
b2f54a6b24 | ||
|
|
39168a321c | ||
|
|
1cd7427e90 | ||
|
|
02122f0002 |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,11 +1,18 @@
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
### vim ###
|
||||
.*.s[a-w][a-z]
|
||||
*.un~
|
||||
Session.vim
|
||||
.netrwhist
|
||||
*~
|
||||
.versions
|
||||
|
||||
### editors ###
|
||||
.vscode
|
||||
.idea
|
||||
*.sublime-*
|
||||
|
||||
### OSX ###
|
||||
.DS_Store
|
||||
@@ -13,11 +20,9 @@ Session.vim
|
||||
.LSOverride
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.idea
|
||||
|
||||
11
.travis.yml
11
.travis.yml
@@ -1,6 +1,13 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
- "0.10"
|
||||
- stable
|
||||
- lts/*
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
|
||||
sudo: false
|
||||
|
||||
58
bower.json
58
bower.json
@@ -1,45 +1,17 @@
|
||||
{
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.1",
|
||||
"authors": [
|
||||
"Faisal Salman <fyzlman@gmail.com>"
|
||||
],
|
||||
"private": false,
|
||||
"main": "src/ua-parser.js",
|
||||
"ignore": [
|
||||
"build",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"contributors": [
|
||||
"Faisal Salman <fyzlman@gmail.com>",
|
||||
"Benjamin Bertrand <bertrand.design@gmail.com>",
|
||||
"Carl C Von Lewin <carlchristianlewin@gmail.com>",
|
||||
"Christopher De Cairos <chris.decairos@gmail.com>",
|
||||
"Davit Barbakadze <jayarjo@gmail.com>",
|
||||
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
||||
"Douglas Li <doug@knotch.it>",
|
||||
"Dumitru Uzun <duzun@mail.ru>",
|
||||
"Erik Hesselink <hesselink@gmail.com>",
|
||||
"Fabian Becker <halfdan@xnorfz.de>",
|
||||
"Hendrik Helwich <h.helwich@iplabs.de>",
|
||||
"Jackpoll <jackpoll123456@gmail.com>",
|
||||
"Jake Mc <startswithaj@users.noreply.github.com>",
|
||||
"John Tantalo <john.tantalo@gmail.com>",
|
||||
"John Yanarella <jmy@codecatalyst.com>",
|
||||
"Jon Buckley <jon@jbuckley.ca>",
|
||||
"Kendall Buchanan <kendall@kendagriff.com>",
|
||||
"Lee Treveil <leetreveil@gmail.com>",
|
||||
"Leonardo <leofiore@libero.it>",
|
||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
||||
"Michael Hess <mhess@connectify.me>",
|
||||
"OtakuSiD <otakusid@gmail.com>",
|
||||
"Ross Noble <rosshnoble@gmail.com>",
|
||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>"
|
||||
],
|
||||
"dependencies": {
|
||||
|
||||
}
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.20",
|
||||
"authors": [
|
||||
"Faisal Salman <f@faisalman.com>"
|
||||
],
|
||||
"private": false,
|
||||
"main": "src/ua-parser.js",
|
||||
"ignore": [
|
||||
"build",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# dependencies
|
||||
JSHINT_DIR="node_modules/jshint/bin/jshint"
|
||||
MOCHA_DIR="node_modules/mocha/bin/mocha"
|
||||
UGLIFY_DIR="node_modules/uglify-js/bin/uglifyjs"
|
||||
|
||||
# check module directory & install if not found
|
||||
function check_module {
|
||||
if ! type $2 &> /dev/null
|
||||
then
|
||||
echo "$2 is not found"
|
||||
if ! type "npm" &> /dev/null
|
||||
then
|
||||
echo "npm is not installed"
|
||||
echo "Exiting"
|
||||
exit 1
|
||||
else
|
||||
echo "Installing $1..."
|
||||
npm install $1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_module "jshint" $JSHINT_DIR
|
||||
check_module "mocha" $MOCHA_DIR
|
||||
check_module "uglify-js" $UGLIFY_DIR
|
||||
|
||||
echo "Verifiying code..."
|
||||
$JSHINT_DIR src/ua-parser.js
|
||||
|
||||
echo "Running test..."
|
||||
$MOCHA_DIR -R nyan test/test.js
|
||||
|
||||
echo "Minifying script..."
|
||||
$UGLIFY_DIR src/ua-parser.js > src/ua-parser.min.js
|
||||
echo "OK"
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.1",
|
||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device", "cpu"],
|
||||
"scripts": ["src/ua-parser.js"],
|
||||
"main": "src/ua-parser.js",
|
||||
"license": "MIT",
|
||||
"development": {
|
||||
"jshint/jshint": "*",
|
||||
"visionmedia/mocha": "*",
|
||||
"mishoo/uglifyjs2": "*"
|
||||
}
|
||||
}
|
||||
1
dist/ua-parser.html
vendored
Normal file
1
dist/ua-parser.html
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<script src="./ua-parser.min.js"></script>
|
||||
9
dist/ua-parser.min.js
vendored
Normal file
9
dist/ua-parser.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
9
dist/ua-parser.pack.js
vendored
Normal file
9
dist/ua-parser.pack.js
vendored
Normal file
File diff suppressed because one or more lines are too long
21
license.md
Normal file
21
license.md
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2019 Faisal Salman <<f@faisalman.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.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
12
package.js
Normal file
12
package.js
Normal file
@@ -0,0 +1,12 @@
|
||||
Package.describe({
|
||||
name: 'faisalman:ua-parser-js',
|
||||
version: '0.7.20',
|
||||
summary: 'Lightweight JavaScript-based user-agent string parser',
|
||||
git: 'https://github.com/faisalman/ua-parser-js.git',
|
||||
documentation: 'readme.md'
|
||||
});
|
||||
|
||||
Package.onUse(function (api) {
|
||||
api.addFiles("src/ua-parser.js");
|
||||
api.export("UAParser");
|
||||
});
|
||||
117
package.json
117
package.json
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"title": "UAParser.js",
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.1",
|
||||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||
"version": "0.7.20",
|
||||
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
|
||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||
"keywords": [
|
||||
"user-agent",
|
||||
@@ -11,63 +11,130 @@
|
||||
"engine",
|
||||
"os",
|
||||
"device",
|
||||
"cpu"
|
||||
"cpu",
|
||||
"jquery-plugin",
|
||||
"ecosystem:jquery"
|
||||
],
|
||||
"homepage": "http://github.com/faisalman/ua-parser-js",
|
||||
"contributors": [
|
||||
"Faisal Salman <fyzlman@gmail.com>",
|
||||
"Aamir Poonawalla <aamir@urx.com>",
|
||||
"Admas <mollases@users.noreply.github.com>",
|
||||
"algenon <m@antonz.ru>",
|
||||
"Alvin Portillo <portilloalvin@gmail.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>",
|
||||
"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>",
|
||||
"Christopher De Cairos <chris.decairos@gmail.com>",
|
||||
"Dario Vladovic <d.vladimyr@gmail.com>",
|
||||
"Davit Barbakadze <jayarjo@gmail.com>",
|
||||
"ddivernois <david-emmanuel.divernois@amadeus.com>",
|
||||
"Demis Palma <demis.palma@gmail.com>",
|
||||
"dhoko <aurelien@protonmail.com>",
|
||||
"dianhe <dianhe@webank.com>",
|
||||
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
||||
"Douglas Li <doug@knotch.it>",
|
||||
"Dumitru Uzun <duzun@mail.ru>",
|
||||
"Dumitru Uzun <contact@duzun.me>",
|
||||
"Eric Schrenker <eric.schrenker@gmail.com>",
|
||||
"Erik Hesselink <hesselink@gmail.com>",
|
||||
"Fabian Becker <halfdan@xnorfz.de>",
|
||||
"Faisal Salman <fyzlman@gmail.com>",
|
||||
"Frédéric Camblor <fcamblor@gmail.com>",
|
||||
"Germán M. Bravo <german.mb@gmail.com>",
|
||||
"Grigory Dmitrenko <grigory@snsk.ru>",
|
||||
"Hendrik Helwich <h.helwich@iplabs.de>",
|
||||
"Jackpoll <jackpoll123456@gmail.com>",
|
||||
"Hermann Ebert <ebbmo@HE.local>",
|
||||
"jackpoll <jackpoll123456@gmail.com>",
|
||||
"Jake Mc <startswithaj@users.noreply.github.com>",
|
||||
"John Tantalo <john.tantalo@gmail.com>",
|
||||
"John Yanarella <jmy@codecatalyst.com>",
|
||||
"Jon Buckley <jon@jbuckley.ca>",
|
||||
"Kendall Buchanan <kendall@kendagriff.com>",
|
||||
"Lee Treveil <leetreveil@gmail.com>",
|
||||
"Leonardo <leofiore@libero.it>",
|
||||
"leonardo <leofiore@libero.it>",
|
||||
"Levente Balogh <balogh.levente.hu@gmail.com>",
|
||||
"Liam Quinn <lquinn@blackberry.com>",
|
||||
"Lithin <lithin@webklipper.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>",
|
||||
"Matt Brophy <matt@brophy.org>",
|
||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
||||
"Maximilian Haupt <mail@maximilianhaupt.com>",
|
||||
"Michael Hess <mhess@connectify.me>",
|
||||
"OtakuSiD <otakusid@gmail.com>",
|
||||
"naoh <naoh.cs03g@nctu.edu.tw>",
|
||||
"Nik Rolls <nik@rolls.cc>",
|
||||
"Nikhil Motiani <nikhil.m@247-inc.com>",
|
||||
"niris <nirisix@gmail.com>",
|
||||
"Nobuo Okada <nookada@yahoo-corp.jp>",
|
||||
"otakuSiD <otakusid@gmail.com>",
|
||||
"Peter Dave Hello <PeterDaveHello@users.noreply.github.com>",
|
||||
"philippsimon <github@philippsimon.de>",
|
||||
"Pieter Hendrickx <pieter.hendrickx@belfius.be>",
|
||||
"Piper Chester <piperchester@gmail.com>",
|
||||
"Robert Tod <robert@qubit.com>",
|
||||
"Ron Korland <ron@testim.io>",
|
||||
"Ross Noble <rosshnoble@gmail.com>",
|
||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>"
|
||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>",
|
||||
"sgautrea <shanegautreau@gmail.com>",
|
||||
"Shane Gautreau <sgautrea@opentext.com>",
|
||||
"Shane Thacker <shane@steadymade.com>",
|
||||
"shchotse <topal@mail.ua>",
|
||||
"Simon Eisenmann <simon@longsleep.org>",
|
||||
"Simon Lang <me@simonlang.org>",
|
||||
"Stiekel <histkc@gmail.com>",
|
||||
"Sylvain Gizard <sylvain.gizard@gmail.com>",
|
||||
"szchenghuang <szchenghuang@gmail.com>",
|
||||
"Vadim Kurachevsky <vadim@hmvs.org>",
|
||||
"Yun Young-jin <yupmin@yupmin-office-macmini.local>"
|
||||
],
|
||||
"main": "src/ua-parser.js",
|
||||
"scripts": {
|
||||
"test": "./build/build.sh"
|
||||
"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"
|
||||
},
|
||||
"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})"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"jshint": "~1.1.0",
|
||||
"mocha": "~1.7.1",
|
||||
"uglify-js": "~1.3.4"
|
||||
"mocha": "~1.8.0",
|
||||
"requirejs": "^2.3.2",
|
||||
"uglify-js": "~2.7.5",
|
||||
"verup": "^1.3.x"
|
||||
},
|
||||
"repository" : {
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "GPLv2",
|
||||
"url": "http://www.gnu.org/licenses/gpl-2.0.html"
|
||||
},
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"dist": "dist",
|
||||
"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"
|
||||
}
|
||||
|
||||
238
readme.md
238
readme.md
@@ -1,49 +1,61 @@
|
||||
# UAParser.js
|
||||
|
||||
Lightweight JavaScript-based User-Agent string parser. Supports browser & node.js environment. Also available as jQuery/Zepto plugin, Component package, Bower package, & AMD module
|
||||
<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 (~17KB when minified / ~6KB 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://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)
|
||||
|
||||
* Author : Faisal Salman <<fyzlman@gmail.com>>
|
||||
* Author : Faisal Salman <<f@faisalman.com>>
|
||||
* Demo : http://faisalman.github.io/ua-parser-js
|
||||
* Source : https://github.com/faisalman/ua-parser-js
|
||||
|
||||
## Features
|
||||
# Constructor
|
||||
|
||||
Extract detailed type of web browser, layout engine, operating system, cpu architecture, and device type/model purely from user-agent string with relatively lightweight footprint (~11KB minified / ~4KB gzipped). Written in vanilla js, which means it doesn't depends on any other library.
|
||||
* `new UAParser([uastring][,extensions])`
|
||||
* returns new instance
|
||||
|
||||

|
||||
* `UAParser([uastring][,extensions])`
|
||||
* returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
||||
|
||||
## Methods
|
||||
# Methods
|
||||
|
||||
* `getBrowser()`
|
||||
* returns `{ name: '', major: '', version: '' }`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```
|
||||
```sh
|
||||
# Possible 'browser.name':
|
||||
Amaya, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome, Chromium,
|
||||
Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, 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, [Mobile] Safari, Mosaic, Mozilla,
|
||||
Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet], Phoenix,
|
||||
Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox,
|
||||
Tizen, UCBrowser, w3m, Yandex
|
||||
2345Explorer, Amaya, Android Browser, Arora, Avant, BIDUBrowser, Baidu,
|
||||
Basilisk, Blazer, Bolt, Bowser, Camino, Chimera, Chrome Headless,
|
||||
Chrome WebView, Chrome, Chromium, Comodo Dragon, Dillo, Dolphin, Doris, Edge,
|
||||
Epiphany, Facebook, Falkon, Fennec, Firebird, Firefox, Flock, GSA, GoBrowser,
|
||||
ICE Browser, IE, IEMobile, IceApe, IceCat, IceDragon, Iceape, Iceweasel,
|
||||
Iridium, Iron, Jasmine, K-Meleon, Kindle, Konqueror, LBBROWSER Line, Links,
|
||||
Lunascape, Lynx, MIUI Browser, Maemo Browser, Maemo, Maxthon, MetaSr Midori,
|
||||
Minimo, Mobile Safari, Mosaic, Mozilla, NetFront, NetSurf, Netfront, Netscape,
|
||||
NokiaBrowser, Oculus Browser, OmniWeb, Opera Coast, Opera Mini, Opera Mobi,
|
||||
Opera Tablet, Opera, PaleMoon, PhantomJS, Phoenix, Polaris, Puffin, QQ,
|
||||
QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari, Samsung Browser,
|
||||
SeaMonkey, Silk, Skyfire, Sleipnir, Slim, SlimBrowser, Swiftfox, Tizen Browser,
|
||||
UCBrowser, Vivaldi, Waterfox, WeChat, Yandex, baidu, iCab, w3m, ...
|
||||
|
||||
# 'browser.version' & 'browser.major' determined dynamically
|
||||
# 'browser.version' determined dynamically
|
||||
```
|
||||
|
||||
* `getDevice()`
|
||||
* returns `{ model: '', type: '', vendor: '' }`
|
||||
|
||||
```
|
||||
```sh
|
||||
# Possible 'device.type':
|
||||
console, mobile, tablet, smarttv
|
||||
console, mobile, tablet, smarttv, wearable, embedded
|
||||
|
||||
# Possible 'device.vendor':
|
||||
Acer, Alcatel, Amazon, Apple, Asus, BenQ, BlackBerry, Dell, GeeksPhone,
|
||||
HP, HTC, Huawei, Jolla, Lenovo, LG, Meizu, Motorola, Nexian, Nintendo, Nokia,
|
||||
Palm, Panasonic, Polytron, RIM, Samsung, Siemens, Sony-Ericsson, Sprint, ZTE
|
||||
Acer, Alcatel, Amazon, Apple, Archos, Asus, BenQ, BlackBerry, Dell, Essential,
|
||||
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
|
||||
```
|
||||
@@ -51,10 +63,10 @@ Palm, Panasonic, Polytron, RIM, Samsung, Siemens, Sony-Ericsson, Sprint, ZTE
|
||||
* `getEngine()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```
|
||||
```sh
|
||||
# Possible 'engine.name'
|
||||
Amaya, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto, Tasman,
|
||||
Trident, w3m, WebKit
|
||||
Amaya, Blink, EdgeHTML, Gecko, Goanna, iCab, KHTML, Links, Lynx, NetFront, NetSurf,
|
||||
Presto, Tasman, Trident, w3m, WebKit
|
||||
|
||||
# 'engine.version' determined dynamically
|
||||
```
|
||||
@@ -62,14 +74,14 @@ Trident, w3m, WebKit
|
||||
* `getOS()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```
|
||||
```sh
|
||||
# Possible 'os.name'
|
||||
AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
|
||||
Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Gentoo, GNU, Haiku, Hurd, iOS,
|
||||
Joli, Linux, Mac OS, Mandriva, MeeGo, Minix, Mint, Morph OS, NetBSD, Nintendo,
|
||||
OpenBSD, OS/2, Palm, PCLinuxOS, Plan9, Playstation, QNX, RedHat, RIM Tablet OS,
|
||||
RISC OS, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen, Ubuntu,
|
||||
UNIX, WebOS, Windows [Phone/Mobile], Zenwalk
|
||||
AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS, Contiki,
|
||||
Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Fuchsia, 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
|
||||
```
|
||||
@@ -77,9 +89,9 @@ UNIX, WebOS, Windows [Phone/Mobile], Zenwalk
|
||||
* `getCPU()`
|
||||
* returns `{ architecture: '' }`
|
||||
|
||||
```
|
||||
```sh
|
||||
# Possible 'cpu.architecture'
|
||||
68k, amd64, arm, ia32, ia64, irix, irix64, mips, mips64, pa-risc, ppc, sparc, sparc64
|
||||
68k, amd64, arm[64], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, sparc[64]
|
||||
```
|
||||
|
||||
* `getResult()`
|
||||
@@ -89,9 +101,11 @@ UNIX, WebOS, Windows [Phone/Mobile], Zenwalk
|
||||
* returns UA string of current instance
|
||||
|
||||
* `setUA(uastring)`
|
||||
* set & parse UA string
|
||||
* set UA string to parse
|
||||
* returns current instance
|
||||
|
||||
## Example
|
||||
|
||||
# Example
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
@@ -110,8 +124,7 @@ UNIX, WebOS, Windows [Phone/Mobile], Zenwalk
|
||||
ua: "",
|
||||
browser: {
|
||||
name: "",
|
||||
version: "",
|
||||
major: ""
|
||||
version: ""
|
||||
},
|
||||
engine: {
|
||||
name: "",
|
||||
@@ -140,7 +153,7 @@ UNIX, WebOS, Windows [Phone/Mobile], Zenwalk
|
||||
// this will also produce the same result (without instantiation):
|
||||
// var result = UAParser(uastring);
|
||||
|
||||
console.log(result.browser); // {name: "Chromium", major: "15", version: "15.0.874.106"}
|
||||
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"
|
||||
@@ -165,61 +178,70 @@ UNIX, WebOS, Windows [Phone/Mobile], Zenwalk
|
||||
</html>
|
||||
```
|
||||
|
||||
### Extending regex patterns
|
||||
|
||||
* `UAParser(uastring[, extensions])`
|
||||
|
||||
Pass your own regexes to extend the limited matching rules.
|
||||
|
||||
```js
|
||||
// Example:
|
||||
var uaString = 'ownbrowser/1.3';
|
||||
var ownBrowser = [[/(ownbrowser)\/((\d+)?[\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION, UAParser.BROWSER.MAJOR]];
|
||||
var parser = new UAParser(uaString, {browser: ownBrowser});
|
||||
console.log(parser.getBrowser()); // {name: "ownbrowser", major: "1", version: "1.3"}
|
||||
```
|
||||
|
||||
### Using node.js
|
||||
## Using node.js
|
||||
|
||||
```sh
|
||||
$ npm install ua-parser-js
|
||||
```
|
||||
|
||||
```js
|
||||
var UAParser = require('ua-parser-js');
|
||||
var parser = new UAParser();
|
||||
var ua = request.headers['user-agent']; // user-agent header from an HTTP request
|
||||
console.log(parser.setUA(ua).getResult());
|
||||
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
|
||||
## Using requirejs
|
||||
|
||||
```js
|
||||
require(['ua-parser'], function(UAParser) {
|
||||
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 component
|
||||
## Using CDN
|
||||
|
||||
```sh
|
||||
$ component install faisalman/ua-parser-js
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/ua-parser-js@0/dist/ua-parser.min.js"></script>
|
||||
```
|
||||
|
||||
```js
|
||||
var UAParser = require('ua-parser-js');
|
||||
var parser = new UAParser();
|
||||
console.log(parser.getResult());
|
||||
```
|
||||
|
||||
### Using bower
|
||||
## Using bower
|
||||
|
||||
```sh
|
||||
$ bower install ua-parser-js
|
||||
```
|
||||
|
||||
### Using jQuery/Zepto ($.ua)
|
||||
## Using meteor
|
||||
|
||||
```sh
|
||||
$ meteor add faisalman:ua-parser-js
|
||||
```
|
||||
|
||||
## Using TypeScript
|
||||
|
||||
```sh
|
||||
$ npm install --save @types/ua-parser-js
|
||||
# Download TS type definition from DefinitelyTyped repository:
|
||||
# https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ua-parser-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)`.
|
||||
|
||||
@@ -240,31 +262,75 @@ 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);
|
||||
```
|
||||
|
||||
## Development
|
||||
## Extending regex patterns
|
||||
|
||||
Verify, test, & minify script
|
||||
* `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 test
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
Then submit a pull request to https://github.com/faisalman/ua-parser-js under `develop` branch.
|
||||
|
||||
# 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://www.paypal.me/faisalman/)
|
||||
|
||||
|
||||
## License
|
||||
# License
|
||||
|
||||
Dual licensed under GPLv2 & MIT
|
||||
MIT License
|
||||
|
||||
Copyright © 2012-2014 Faisal Salman <<fyzlman@gmail.com>>
|
||||
Copyright (c) 2012-2019 Faisal Salman <<f@faisalman.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:
|
||||
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
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
799
src/ua-parser.js
Normal file → Executable file
799
src/ua-parser.js
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
1
src/ua-parser.min.js
vendored
1
src/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -47,6 +47,14 @@
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv7",
|
||||
"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" : "Pocket PC",
|
||||
"ua" : "Opera/9.7 (Windows Mobile; PPC; Opera Mobi/35166; U; en) Presto/2.2.1",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"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" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@@ -8,6 +26,15 @@
|
||||
"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)",
|
||||
@@ -61,5 +88,14 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
582
test/mediaplayer-test.json
Normal file
582
test/mediaplayer-test.json
Normal file
@@ -0,0 +1,582 @@
|
||||
[
|
||||
{
|
||||
"desc" : "Coremedia",
|
||||
"ua" : "Apple Mac OS X v10.6.4 CoreMedia v1.0.0.10F2108",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "CoreMedia",
|
||||
"version" : "1.0.0.10F2108",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AppleCoreMedia",
|
||||
"ua" : "AppleCoreMedia/1.0.0.10A403 (iPad; U; CPU OS 6_0 like Mac OS X; it_it)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "AppleCoreMedia",
|
||||
"version" : "1.0.0.10A403",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AppleTv",
|
||||
"ua" : "AppleTV/3.0.2 (Macintosh; Intel Mac OS X 10.4.7) AppleWebKit/528.18",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "528.18",
|
||||
"major" : "528"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Aqualung",
|
||||
"ua" : "Aqualung/R-1114",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Aqualung",
|
||||
"version" : "R-1114",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Ares",
|
||||
"ua" : "Ares 2.2.4.3048",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Ares",
|
||||
"version" : "2.2.4.3048",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Audacious",
|
||||
"ua" : "Audacious/3.2.2 neon/0.29.3",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Audacious",
|
||||
"version" : "3.2.2",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AudiMusicStream",
|
||||
"ua" : "AudiMusicStream/3020.130826151911",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "AudiMusicStream",
|
||||
"version" : "3020.130826151911",
|
||||
"major" : "3020"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BASS",
|
||||
"ua" : "BASS/2.4",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BASS",
|
||||
"version" : "2.4",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BSPlayer",
|
||||
"ua" : "BSPlayer/2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BSPlayer",
|
||||
"version" : "2",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Core",
|
||||
"ua" : "CORE/6.506.4.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "CORE",
|
||||
"version" : "6.506.4.1",
|
||||
"major" : "6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Clementine",
|
||||
"ua" : "Clementine 1.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Clementine",
|
||||
"version" : "1.1",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Dalvik",
|
||||
"ua" : "Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5830L Build/FROYO)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Dalvik",
|
||||
"version" : "1.2.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NexPlayer",
|
||||
"ua" : "E97510d/ Player/NexPlayer 4.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NexPlayer",
|
||||
"version" : "4.0",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "FLRP",
|
||||
"ua" : "FLRP/2.5 CFNetwork/609.1.4 Darwin/13.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Flip Player",
|
||||
"version" : "2.5",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "FStream",
|
||||
"ua" : "FStream",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "FStream",
|
||||
"version" : "undefined",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "GStreamer",
|
||||
"ua" : "GStreamer souphttpsrc (compatible; LG NetCast.TV-2012) libsoup/2.34.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "GStreamer",
|
||||
"version" : "2.34.2",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "GnomeMplayer",
|
||||
"ua" : "GnomeMplayer/1.0.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "GnomeMplayer",
|
||||
"version" : "1.0.2",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "HTC Streaming Player",
|
||||
"ua" : "HTC Streaming Player htc_asia_wwe / 1.0 / endeavoru / 4.1.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "HTC Streaming Player",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "HTC One S",
|
||||
"ua" : "HTC_One_S/3.16.111.10",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "HTC One S",
|
||||
"version" : "3.16.111.10",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Java",
|
||||
"ua" : "Java/1.4.1_04",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Java",
|
||||
"version" : "1.4.1_04",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LG Player",
|
||||
"ua" : "LG Player 1.0; Android",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LG Player",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NexPlayer",
|
||||
"ua" : "LG-P700/V10k-DEC-12-2012 Player/NexPlayer 4.0 for Android",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NexPlayer",
|
||||
"version" : "4.0",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LG Player",
|
||||
"ua" : "LGE400/V10b Player/LG Player 1.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LG Player",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Lavf",
|
||||
"ua" : "Lavf52.111.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Lavf",
|
||||
"version" : "52.111.0",
|
||||
"major" : "52"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Lyssna",
|
||||
"ua" : "Lyssna/46 CFNetwork/609.1.4 Darwin/13.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Lyssna",
|
||||
"version" : "46",
|
||||
"major" : "46"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer",
|
||||
"ua" : "MPlayer 1.1-4.2.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "1.1-4.2.1",
|
||||
"major" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer SVN",
|
||||
"ua" : "MPlayer SVN-r33713-4.6.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "r33713-4.6.1",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer ubuntu",
|
||||
"ua" : "MPlayer svn r34540 (Ubuntu), built with gcc-4.6",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "r34540",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MoC",
|
||||
"ua" : "Music On Console/2.5.0-beta1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Music On Console",
|
||||
"version" : "2.5.0-beta1",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPD",
|
||||
"ua" : "Music Player Daemon 0.17.4",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Music Player Daemon",
|
||||
"version" : "0.17.4",
|
||||
"major" : "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NSPlayer",
|
||||
"ua" : "NSPlayer/11.0.5358.4827 WMFSDK/11.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NSPlayer",
|
||||
"version" : "11.0.5358.4827",
|
||||
"major" : "11"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Nero Home",
|
||||
"ua" : "Nero Home/1.5.3.0 (compatible; Nero AG; Nero Home 1.5.3.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Nero Home",
|
||||
"version" : "1.5.3.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NexPlayer",
|
||||
"ua" : "NexPlayer 4.0 for Android( stagefright alternative )",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NexPlayer",
|
||||
"version" : "4.0",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Nokia3xx",
|
||||
"ua" : "Nokia303/14.87 CLDC-1.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Nokia303",
|
||||
"version" : "14.87",
|
||||
"major" : "14"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer SVN Sherpya",
|
||||
"ua" : "MPlayer Sherpya-SVN-r33124-4.2.5",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "r33124-4.2.5",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Philips Songbird",
|
||||
"ua" : "NotMoz/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.2.3) Gecko/20101207 Philips-Songbird/5.4.1980 Songbird/1.9.4 (20110302030555)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Songbird",
|
||||
"version" : "1.9.4",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Ossproxy",
|
||||
"ua" : "OSSProxy 1.3.336.320 (Build 336.320 Win32 en-us)(Aug 16 2013 17:38:43)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "OSSProxy",
|
||||
"version" : "1.3.336.320",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Winamp3",
|
||||
"ua" : "Nullsoft Winamp3 version 3.0 (compatible)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Winamp",
|
||||
"version" : "3.0",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "PSP",
|
||||
"ua" : "PSP-InternetRadioPlayer/1.00",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "PSP-InternetRadioPlayer",
|
||||
"version" : "1.00",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "urllib",
|
||||
"ua" : "Python-urllib/2.7",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Python-urllib",
|
||||
"version" : "2.7",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "QuickTime",
|
||||
"ua" : "QuickTime/7.5.6 (qtver=7.5.6;cpu=IA32;os=Mac 10.5.8)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "QuickTime",
|
||||
"version" : "7.5.6",
|
||||
"major" : "7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RMA",
|
||||
"ua" : "RMA/1.0 (compatible; RealMedia)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "RMA",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RadioApp",
|
||||
"ua" : "RadioApp/1.0 CFNetwork/609.1.4 Darwin/11.4.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "RadioApp",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RadioClientApplication",
|
||||
"ua" : "RadioClientApplication/20 CFNetwork/609.1.4 Darwin/13.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "RadioClientApplication",
|
||||
"version" : "20",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "stagefright",
|
||||
"ua" : "Samsung GT-I9070 stagefright/1.1 (Linux;Android 2.3.6)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "stagefright",
|
||||
"version" : "1.1",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Soundtap",
|
||||
"ua" : "Soundtap/1.2.4 CFNetwork/672.0.2 Darwin/14.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Soundtap",
|
||||
"version" : "1.2.4",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Streamium",
|
||||
"ua" : "Streamium/1.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Streamium",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Totem",
|
||||
"ua" : "Totem/3.0.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Totem",
|
||||
"version" : "3.0.1",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "VLC",
|
||||
"ua" : "VLC media player - version 0.8.6c Janus - (c) 1996-2007 the VideoLAN team",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "VLC",
|
||||
"version" : "0.8.6c",
|
||||
"major" : "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "VLC",
|
||||
"ua" : "VLC/2.0.0 LibVLC/2.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "VLC",
|
||||
"version" : "2.0.0",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Videos",
|
||||
"ua" : "Videos/3.8.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Video",
|
||||
"version" : "3.8.2",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Wget",
|
||||
"ua" : "Wget/1.12 (darwin10.7.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Wget",
|
||||
"version" : "1.12",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Winamp",
|
||||
"ua" : "Winamp 2.81",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Winamp",
|
||||
"version" : "2.81",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Winamp",
|
||||
"ua" : "WinampMPEG/2.00",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Winamp",
|
||||
"version" : "2.00",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows Media Player",
|
||||
"ua" : "Windows-Media-Player/10.00.00.4019",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows Media Player",
|
||||
"version" : "10.00.00.4019",
|
||||
"major" : "10"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "XBMC",
|
||||
"ua" : "XBMC/12.0 Git:20130127-fb595f2 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "XBMC",
|
||||
"version" : "12.0",
|
||||
"major" : "12"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "rad.io",
|
||||
"ua" : "rad.io 1.18.1 rv:593 (iPhone 4S; iPhone OS 7.0.4; it_IT)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "rad.io",
|
||||
"version" : "1.18.1",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BE-Test",
|
||||
"ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BE Test",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -71,6 +71,15 @@
|
||||
"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)",
|
||||
@@ -98,6 +107,15 @@
|
||||
"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)",
|
||||
@@ -136,11 +154,11 @@
|
||||
},
|
||||
{
|
||||
"desc" : "Tizen",
|
||||
"ua" : "",
|
||||
"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" : "",
|
||||
"version" : ""
|
||||
"name" : "Tizen",
|
||||
"version" : "2.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -152,6 +170,15 @@
|
||||
"version" : "2.2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Sailfish",
|
||||
"ua" : "Mozilla/5.0 (Linux; U; Sailfish 3.0; Mobile; rv:45.0) Gecko/45.0 Firefox/45.0 SailfishBrowser/1.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Sailfish",
|
||||
"version" : "3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS",
|
||||
"ua" : "",
|
||||
@@ -242,6 +269,15 @@
|
||||
"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" : "",
|
||||
@@ -262,11 +298,20 @@
|
||||
},
|
||||
{
|
||||
"desc" : "Ubuntu",
|
||||
"ua" : "",
|
||||
"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" : "",
|
||||
"version" : ""
|
||||
"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"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -397,11 +442,20 @@
|
||||
},
|
||||
{
|
||||
"desc" : "Chromium OS",
|
||||
"ua" : "",
|
||||
"ua" : "Mozilla/5.0 (X11; CrOS x86_64 10575.58.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "",
|
||||
"version" : ""
|
||||
"name" : "Chromium OS",
|
||||
"version" : "10575.58.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Fuchsia",
|
||||
"ua" : "Mozilla/5.0 (X11; Fuchsia x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3557.0 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Fuchsia",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -449,6 +503,15 @@
|
||||
"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",
|
||||
@@ -472,17 +535,17 @@
|
||||
"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 X",
|
||||
"name" : "Mac OS",
|
||||
"version" : "10.6.8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Haiku",
|
||||
"ua" : "",
|
||||
"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" : "",
|
||||
"version" : ""
|
||||
"name" : "Haiku",
|
||||
"version" : "R1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
57
test/test.js
57
test/test.js
@@ -1,4 +1,5 @@
|
||||
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');
|
||||
@@ -43,15 +44,6 @@ describe('UAParser()', function () {
|
||||
assert.deepEqual(UAParser(ua), new UAParser().setUA(ua).getResult());
|
||||
});
|
||||
|
||||
describe('Injected Browser', function () {
|
||||
var uaString = 'ownbrowser/1.3';
|
||||
var ownBrowser = [[/(ownbrowser)\/((\d+)?[\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION, UAParser.BROWSER.MAJOR]];
|
||||
var parser = new UAParser(uaString, {browser: ownBrowser});
|
||||
assert.equal(parser.getBrowser().name, 'ownbrowser');
|
||||
assert.equal(parser.getBrowser().major, '1');
|
||||
assert.equal(parser.getBrowser().version, '1.3');
|
||||
});
|
||||
|
||||
for (var i in methods) {
|
||||
describe(methods[i]['title'], function () {
|
||||
for (var j in methods[i]['list']) {
|
||||
@@ -72,3 +64,50 @@ for (var i in methods) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"title": "UAParser.js",
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.1",
|
||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||
"keywords": [
|
||||
"user-agent",
|
||||
"parser",
|
||||
"browser",
|
||||
"engine",
|
||||
"os",
|
||||
"device",
|
||||
"cpu"
|
||||
],
|
||||
"homepage": "https://faisalman.github.com/ua-parser-js",
|
||||
"author": {
|
||||
"name": "Faisal Salman",
|
||||
"email": "fyzlman@gmail.com"
|
||||
},
|
||||
"dependencies": {
|
||||
"jquery": ">=1.5"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||
}
|
||||
],
|
||||
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
||||
"docs": "https://github.com/faisalman/ua-parser-js",
|
||||
"download": "https://raw.github.com/faisalman/ua-parser-js/master/src/ua-parser.min.js"
|
||||
}
|
||||
Reference in New Issue
Block a user