ua-parser-js
Advanced tools
Comparing version 0.5.20 to 0.5.22
{ | ||
"name": "ua-parser-js", | ||
"version": "0.5.20", | ||
"version": "0.5.22", | ||
"description": "Lightweight JavaScript-based user-agent string parser", | ||
@@ -5,0 +5,0 @@ "keywords": ["user-agent", "parser", "browser", "engine", "os", "device"], |
{ | ||
"title": "UA-Parser.JS", | ||
"name": "ua-parser-js", | ||
"version": "0.5.20", | ||
"version": "0.5.22", | ||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)", | ||
@@ -25,3 +25,3 @@ "description": "Lightweight JavaScript-based user-agent string parser", | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha -R spec" | ||
"test": "./build/build.sh" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -5,3 +5,3 @@ # UAParser.js | ||
[![Build Status](https://travis-ci.org/faisalman/ua-parser-js.png)](https://travis-ci.org/faisalman/ua-parser-js) | ||
[![Build Status](https://travis-ci.org/faisalman/ua-parser-js.png?branch=master)](https://travis-ci.org/faisalman/ua-parser-js) | ||
@@ -25,7 +25,11 @@ * Author : Faisalman <<fyzlman@gmail.com>> | ||
# 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, | ||
Iceweasel, IE [Mobile], 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, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox, Tizen, UCBrowser, w3m, Yandex | ||
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, Iceweasel, | ||
IE [Mobile], 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, RockMelt, | ||
Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox, Tizen, UCBrowser, w3m, Yandex | ||
# 'browser.version' & 'browser.major' determined dynamically | ||
``` | ||
@@ -41,4 +45,7 @@ | ||
# Possible 'device.vendor': | ||
Acer, Alcatel, Apple, Asus, BenQ, BlackBerry, Dell, GeeksPhone, HP, HTC, Huawei, Lenovo, LG, Meizu, Motorola, Nexian, | ||
Nintendo, Nokia, Palm, Panasonic, RIM, Samsung, Siemens, Sony-Ericsson, Sprint, ZTE | ||
Acer, Alcatel, Apple, Asus, BenQ, BlackBerry, Dell, GeeksPhone, HP, HTC, Huawei, | ||
Lenovo, LG, Meizu, Motorola, Nexian, Nintendo, Nokia, Palm, Panasonic, | ||
RIM, Samsung, Siemens, Sony-Ericsson, Sprint, ZTE | ||
# 'device.model' determined dynamically | ||
``` | ||
@@ -51,3 +58,6 @@ | ||
# Possible 'engine.name' | ||
Amaya, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto, Tasman, Trident, w3m, WebKit | ||
Amaya, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto, Tasman, | ||
Trident, w3m, WebKit | ||
# 'engine.version' determined dynamically | ||
``` | ||
@@ -60,6 +70,10 @@ | ||
# 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, Slackware, | ||
Solaris, SUSE, Symbian, Tizen, Ubuntu, UNIX, WebOS, Windows [Phone/Mobile], Zenwalk | ||
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, Slackware, Solaris, SUSE, Symbian, Tizen, Ubuntu, UNIX, WebOS, | ||
Windows [Phone/Mobile], Zenwalk | ||
# 'os.version' determined dynamically | ||
``` | ||
@@ -69,6 +83,4 @@ | ||
* returns `{ browser: {}, device: {}, engine: {}, os: {} }` | ||
* `getUA()` | ||
* returns UA string of current instance | ||
* `setUA(uastring)` | ||
@@ -146,3 +158,3 @@ * set & parse UA string | ||
## Using requirejs | ||
### Using requirejs | ||
@@ -156,3 +168,3 @@ ```js | ||
## Using node.js | ||
### Using node.js | ||
@@ -169,3 +181,3 @@ ```sh | ||
## Using component | ||
### Using component | ||
@@ -182,3 +194,3 @@ ```sh | ||
## Using bower | ||
### Using bower | ||
@@ -189,3 +201,3 @@ ```sh | ||
## Using jQuery.ua | ||
### Using jQuery.ua | ||
@@ -207,5 +219,5 @@ Although written in vanilla js (which means it doesn't depends on jQuery), if you're using jQuery, this library will automatically detect and create `$.ua` object based on browser's user-agent. In case you need, `UAParser` constructor is still present in global though. To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`. | ||
// 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($.ua.engine.name); // "Webkit" | ||
console.log($.ua.browser.version); // "4.0" | ||
console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4 | ||
@@ -212,0 +224,0 @@ ``` |
@@ -1,2 +0,2 @@ | ||
// UAParser.js v0.5.20 | ||
// UAParser.js v0.5.22 | ||
// Lightweight JavaScript-based User-Agent string parser | ||
@@ -18,5 +18,6 @@ // https://github.com/faisalman/ua-parser-js | ||
var EMPTY = '', | ||
FUNC = 'function', | ||
UNDEF = 'undefined', | ||
OBJ = 'object', | ||
UNKNOWN = '?', | ||
FUNC_TYPE = 'function', | ||
UNDEF_TYPE = 'undefined', | ||
OBJ_TYPE = 'object', | ||
MAJOR = 'major', | ||
@@ -33,2 +34,17 @@ MODEL = 'model', | ||
/////////// | ||
// Helper | ||
////////// | ||
var util = { | ||
has : function (str1, str2) { | ||
return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1; | ||
}, | ||
is : function (obj, str) { | ||
return typeof obj === str; | ||
} | ||
}; | ||
/////////////// | ||
@@ -41,8 +57,6 @@ // Map helper | ||
regex : function () { | ||
rgx : function () { | ||
var result, i, j, k, l, m, args = arguments; | ||
// loop through all regexes maps | ||
for (i = 0; i < args.length; i += 2) { | ||
for (var result, i = 0, j, k, p, q, matches, match, args = arguments; i < args.length; i += 2) { | ||
@@ -53,32 +67,38 @@ var regex = args[i], // even sequence (0,2,4,..) | ||
// construct object barebones | ||
if (typeof result === UNDEF) { | ||
if (util.is(result, UNDEF_TYPE)) { | ||
result = {}; | ||
for (k = 0; k < props.length; k++) { | ||
if (typeof props[k] === OBJ) { | ||
result[props[k][0]] = undefined; | ||
for (p in props) { | ||
q = props[p]; | ||
if (util.is(q, OBJ_TYPE)) { | ||
result[q[0]] = undefined; | ||
} else { | ||
result[props[k]] = undefined; | ||
result[q] = undefined; | ||
} | ||
} | ||
if (this.getUA().toString() === EMPTY) { | ||
return result; | ||
} | ||
} | ||
// try matching uastring with regexes | ||
for (j = 0; j < regex.length; j++) { | ||
l = regex[j].exec(this.getUA()); | ||
if (!!l) { | ||
for (k = 0; k < props.length; k++) { | ||
m = l[k + 1]; | ||
if (typeof props[k] === OBJ && props[k].length === 2) { | ||
result[props[k][0]] = props[k][1]; | ||
} else if (typeof props[k] === OBJ && props[k].length === 3) { | ||
if (typeof props[k][1] === FUNC && !(props[k][1].exec && props[k][1].test)) { | ||
result[props[k][0]] = m ? props[k][1].call(this, m, props[k][2]) : undefined; | ||
} else { | ||
result[props[k][0]] = m ? m.replace(props[k][1], props[k][2]) : undefined; | ||
for (j = k = 0; j < regex.length; j++) { | ||
matches = regex[j].exec(this.getUA()); | ||
if (!!matches) { | ||
for (p in props) { | ||
match = matches[++k]; | ||
q = props[p]; | ||
// check if given property is actually array | ||
if (util.is(q, OBJ_TYPE)) { | ||
if (q.length == 2) { | ||
// assign given value, ignore regex match | ||
result[q[0]] = q[1]; | ||
} else if (q.length == 3) { | ||
// check whether function or regex | ||
if (util.is(q[1], FUNC_TYPE) && !(q[1].exec && q[1].test)) { | ||
// call function (usually string mapper) | ||
result[q[0]] = match ? q[1].call(this, match, q[2]) : undefined; | ||
} else { | ||
// sanitize match using given regex | ||
result[q[0]] = match ? match.replace(q[1], q[2]) : undefined; | ||
} | ||
} | ||
} else { | ||
result[props[k]] = m ? m : undefined; | ||
result[q] = match ? match : undefined; | ||
} | ||
@@ -90,3 +110,3 @@ } | ||
if(!!l) break; // break the loop immediately if match found | ||
if(!!matches) break; // break the loop immediately if match found | ||
} | ||
@@ -96,15 +116,14 @@ return result; | ||
string : function (str, map) { | ||
str : function (str, map) { | ||
for (var i in map) { | ||
if (map.hasOwnProperty(i)) { | ||
if (typeof map[i] === OBJ && map[i].length > 0) { | ||
for (var j = 0; j < map[i].length; j++) { | ||
if (str.toLowerCase().indexOf(map[i][j].toLowerCase()) !== -1) { | ||
return (i.toString() === UNDEF) ? undefined : i; | ||
} | ||
// check if array | ||
if (util.is(map[i], OBJ_TYPE) && map[i].length > 0) { | ||
for (var j in map[i]) { | ||
if (util.has(map[i][j], str)) { | ||
return (i === UNKNOWN) ? undefined : i; | ||
} | ||
} else if (str.toLowerCase().indexOf(map[i].toLowerCase()) !== -1) { | ||
return (i.toString() === UNDEF) ? undefined : i; | ||
} | ||
} else if (util.has(map[i], str)) { | ||
return (i === UNKNOWN) ? undefined : i; | ||
} | ||
@@ -127,10 +146,10 @@ } | ||
major : { | ||
'1' : ['/85', '/125', '/312'], | ||
'2' : ['/412', '/416', '/417', '/419'], | ||
'undefined' : '/' | ||
'1' : ['/8', '/1', '/3'], | ||
'2' : '/4', | ||
'?' : '/' | ||
}, | ||
version : { | ||
'1.0' : '/85', | ||
'1.2' : '/125', | ||
'1.3' : '/312', | ||
'1.0' : '/8', | ||
'1.2' : '/1', | ||
'1.3' : '/3', | ||
'2.0' : '/412', | ||
@@ -140,3 +159,3 @@ '2.0.2' : '/416', | ||
'2.0.4' : '/419', | ||
'undefined' : '/' | ||
'?' : '/' | ||
} | ||
@@ -202,3 +221,3 @@ } | ||
// Trident based | ||
/(avant\sbrowser|iemobile|slimbrowser|baidubrowser)[\/\s]?((\d+)?[\w\.]*)/i, | ||
/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i, | ||
// Avant/IEMobile/SlimBrowser/Baidu | ||
@@ -235,7 +254,7 @@ /ms(ie)\s((\d+)?[\w\.]+)/i, // Internet Explorer | ||
/applewebkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i // Safari < 3.0 | ||
], [NAME, [MAJOR, mapper.string, maps.browser.oldsafari.major], [VERSION, mapper.string, maps.browser.oldsafari.version]], [ | ||
/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i // Safari < 3.0 | ||
], [NAME, [MAJOR, mapper.str, maps.browser.oldsafari.major], [VERSION, mapper.str, maps.browser.oldsafari.version]], [ | ||
/(konqueror)\/((\d+)?[\w\.]+)/i, // Konqueror | ||
/(applewebkit|khtml)\/((\d+)?[\w\.]+)/i | ||
/(webkit|khtml)\/((\d+)?[\w\.]+)/i | ||
], [NAME, VERSION, MAJOR], [ | ||
@@ -292,7 +311,10 @@ | ||
/(nintendo|playstation)\s([wids3portablev]+)/i // Nintendo/Playstation | ||
/(nintendo)\s([wids3u]+)/i // Nintendo | ||
], [VENDOR, MODEL, [TYPE, CONSOLE]], [ | ||
/((playstation)\s[3portablevi]+)/i // Playstation | ||
], [[VENDOR, 'Sony'], MODEL, [TYPE, CONSOLE]], [ | ||
/(sprint\s(\w+))/i // Sprint Phones | ||
], [[VENDOR, mapper.string, maps.device.sprint.vendor], [MODEL, mapper.string, maps.device.sprint.model], [TYPE, MOBILE]], [ | ||
], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [ | ||
@@ -340,6 +362,4 @@ /(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC | ||
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m | ||
/(khtml)\/([\w\.]+)/i, // KHTML | ||
/(tasman)\s([\w\.]+)/i, // Tasman | ||
/(links)\s\(([\w\.]+)/i, // Links | ||
/(icab)[\/\s]([2-3]\.[\d\.]+)/i // iCab | ||
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links | ||
/(icab)[\/\s]([23]\.[\d\.]+)/i // iCab | ||
], [NAME, VERSION], [ | ||
@@ -356,5 +376,5 @@ | ||
/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i | ||
], [NAME, [VERSION, mapper.string, maps.os.windows.version]], [ | ||
], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [ | ||
/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i | ||
], [[NAME, 'Windows'], [VERSION, mapper.string, maps.os.windows.version]], [ | ||
], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [ | ||
@@ -375,3 +395,3 @@ // Mobile/Embedded OS | ||
// Console | ||
/(nintendo|playstation)\s([wids3portablev]+)/i, // Nintendo/Playstation | ||
/(nintendo|playstation)\s([wids3portablevu]+)/i, // Nintendo/Playstation | ||
@@ -395,3 +415,3 @@ // GNU/Linux based | ||
// BSD based | ||
/\s(\w*bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/DragonFly | ||
/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly | ||
], [NAME, VERSION],[ | ||
@@ -421,3 +441,3 @@ | ||
var UAParser = function UAParser (uastring) { | ||
var UAParser = function (uastring) { | ||
@@ -430,12 +450,12 @@ var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); | ||
this.getBrowser = function () { | ||
return mapper.regex.apply(this, regexes.browser); | ||
return mapper.rgx.apply(this, regexes.browser); | ||
}; | ||
this.getDevice = function () { | ||
return mapper.regex.apply(this, regexes.device); | ||
return mapper.rgx.apply(this, regexes.device); | ||
}; | ||
this.getEngine = function () { | ||
return mapper.regex.apply(this, regexes.engine); | ||
return mapper.rgx.apply(this, regexes.engine); | ||
}; | ||
this.getOS = function () { | ||
return mapper.regex.apply(this, regexes.os); | ||
return mapper.rgx.apply(this, regexes.os); | ||
}; | ||
@@ -467,9 +487,9 @@ this.getResult = function() { | ||
// check js environment | ||
if (typeof exports !== UNDEF && !/\[object\s[DOM]*Window\]/.test(global.toString())) { | ||
if (!util.is(exports, UNDEF_TYPE)) { | ||
// nodejs env | ||
if (typeof module !== UNDEF && module.exports) { | ||
if (!util.is(module, UNDEF_TYPE) && module.exports) { | ||
exports = module.exports = UAParser; | ||
} | ||
exports.UAParser = UAParser; | ||
} else if (typeof define === FUNC && define.amd) { | ||
} else if (util.is(define, FUNC_TYPE) && define.amd) { | ||
// requirejs env | ||
@@ -482,14 +502,15 @@ define(function() { | ||
window.UAParser = UAParser; | ||
// jQuery specific | ||
if (typeof window.jQuery !== UNDEF) { | ||
// jQuery specific (optional) | ||
if (!util.is(window.jQuery, UNDEF_TYPE)) { | ||
var $ = window.jQuery; | ||
var parser = new UAParser(); | ||
window.jQuery.ua = parser.getResult(); | ||
window.jQuery.ua.get = function() { | ||
$.ua = parser.getResult(); | ||
$.ua.get = function() { | ||
return parser.getUA(); | ||
}; | ||
window.jQuery.ua.set = function(uastring) { | ||
$.ua.set = function(uastring) { | ||
parser.setUA(uastring); | ||
var result = parser.getResult(); | ||
for (var prop in result) { | ||
window.jQuery.ua[prop] = result[prop]; | ||
$.ua[prop] = result[prop]; | ||
} | ||
@@ -496,0 +517,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
// UAParser.js v0.5.20 | ||
// UAParser.js v0.5.22 | ||
// Lightweight JavaScript-based User-Agent string parser | ||
@@ -7,2 +7,2 @@ // https://github.com/faisalman/ua-parser-js | ||
// Dual licensed under GPLv2 & MIT | ||
(function(e,t){"use strict";var n="",r="function",i="undefined",s="object",o="major",u="model",a="name",f="type",l="vendor",c="version",h="console",p="mobile",d="tablet",v={regex:function(){var e,o,u,a,f,l,c=arguments;for(o=0;o<c.length;o+=2){var h=c[o],p=c[o+1];if(typeof e===i){e={};for(a=0;a<p.length;a++)typeof p[a]===s?e[p[a][0]]=t:e[p[a]]=t;if(this.getUA().toString()===n)return e}for(u=0;u<h.length;u++){f=h[u].exec(this.getUA());if(!!f){for(a=0;a<p.length;a++)l=f[a+1],typeof p[a]===s&&p[a].length===2?e[p[a][0]]=p[a][1]:typeof p[a]===s&&p[a].length===3?typeof p[a][1]===r&&(!p[a][1].exec||!p[a][1].test)?e[p[a][0]]=l?p[a][1].call(this,l,p[a][2]):t:e[p[a][0]]=l?l.replace(p[a][1],p[a][2]):t:e[p[a]]=l?l:t;break}}if(!!f)break}return e},string:function(e,n){for(var r in n)if(n.hasOwnProperty(r))if(typeof n[r]===s&&n[r].length>0){for(var o=0;o<n[r].length;o++)if(e.toLowerCase().indexOf(n[r][o].toLowerCase())!==-1)return r.toString()===i?t:r}else if(e.toLowerCase().indexOf(n[r].toLowerCase())!==-1)return r.toString()===i?t:r;return e}},m={browser:{oldsafari:{major:{1:["/85","/125","/312"],2:["/412","/416","/417","/419"],"undefined":"/"},version:{"1.0":"/85",1.2:"/125",1.3:"/312","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","undefined":"/"}}},device:{sprint:{model:{"Evo Shift 4G":"7373KT"},vendor:{HTC:"APA",Sprint:"Sprint"}}},os:{windows:{version:{ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",RT:"ARM"}}}},g={browser:[[/(opera\smini)\/((\d+)?[\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i,/(opera).+version\/((\d+)?[\w\.]+)/i,/(opera)[\/\s]+((\d+)?[\w\.]+)/i],[a,c,o],[/\s(opr)\/((\d+)?[\w\.]+)/i],[[a,"Opera"],c,o],[/(kindle)\/((\d+)?[\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,/(avant\sbrowser|iemobile|slimbrowser|baidubrowser)[\/\s]?((\d+)?[\w\.]*)/i,/ms(ie)\s((\d+)?[\w\.]+)/i,/(rekonq)((?:\/)[\w\.]+)*/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i],[a,c,o],[/(yabrowser)\/((\d+)?[\w\.]+)/i],[[a,"Yandex"],c,o],[/(comodo_dragon)\/((\d+)?[\w\.]+)/i],[[a,/_/g," "],c,o],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i],[a,c,o],[/(dolfin)\/((\d+)?[\w\.]+)/i],[[a,"Dolphin"],c,o],[/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i],[[a,"Chrome"],c,o],[/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i],[c,o,[a,"Mobile Safari"]],[/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i],[c,o,a],[/applewebkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i],[a,[o,v.string,m.browser.oldsafari.major],[c,v.string,m.browser.oldsafari.version]],[/(konqueror)\/((\d+)?[\w\.]+)/i,/(applewebkit|khtml)\/((\d+)?[\w\.]+)/i],[a,c,o],[/(navigator|netscape)\/((\d+)?[\w\.-]+)/i],[[a,"Netscape"],c,o],[/(swiftfox)/i,/(iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i,/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?((\d+)?[\w\.]+)/i,/(links)\s\(((\d+)?[\w\.]+)/i,/(gobrowser)\/?((\d+)?[\w\.]+)*/i,/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i,/(mosaic)[\/\s]((\d+)?[\w\.]+)/i],[a,c,o]],device:[[/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i],[u,l,[f,d]],[/(hp).+(touchpad)/i,/(kindle)\/([\w\.]+)/i,/\s(nook)[\w\s]+build\/(\w+)/i,/(dell)\s(strea[kpr\s\d]*[\dko])/i],[l,u,[f,d]],[/\((ip[honed]+);.+(apple)/i],[u,l,[f,p]],[/(blackberry)[\s-]?(\w+)/i,/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola)[\s_-]?([\w-]+)*/i,/(hp)\s([\w\s]+\w)/i,/(asus)-?(\w+)/i],[l,u,[f,p]],[/\((bb10);\s(\w+)/i],[[l,"BlackBerry"],u,[f,p]],[/android.+((transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+))/i],[[l,"Asus"],u,[f,d]],[/(sony)\s(tablet\s[ps])/i],[l,u,[f,d]],[/(nintendo|playstation)\s([wids3portablev]+)/i],[l,u,[f,h]],[/(sprint\s(\w+))/i],[[l,v.string,m.device.sprint.vendor],[u,v.string,m.device.sprint.model],[f,p]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w+)*/i,/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|;\ssony)[_\s-]?([\w-]+)*/i],[l,[u,/_/g," "],[f,p]],[/\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i,/(mot)[\s-]?(\w+)*/i],[[l,"Motorola"],u,[f,p]],[/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i],[[l,"Motorola"],u,[f,d]],[/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n8000|sgh-t8[56]9))/i],[[l,"Samsung"],u,[f,d]],[/((s[cgp]h-\w+|gt-\w+|galaxy\snexus))/i,/(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i,/sec-((sgh\w+))/i],[[l,"Samsung"],u,[f,p]],[/(sie)-(\w+)*/i],[[l,"Siemens"],u,[f,p]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]+)*/i],[[l,"Nokia"],u,[f,p]],[/android\s3\.[\s\w-;]{10}((a\d{3}))/i],[[l,"Acer"],u,[f,d]],[/android\s3\.[\s\w-;]{10}(lg?)-([06cv9]{3,4})/i],[[l,"LG"],u,[f,d]],[/(lg)[e;\s-\/]+(\w+)*/i],[[l,"LG"],u,[f,p]],[/(mobile|tablet);.+rv\:.+gecko\//i],[f,l,u]],engine:[[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i,/(khtml)\/([\w\.]+)/i,/(tasman)\s([\w\.]+)/i,/(links)\s\(([\w\.]+)/i,/(icab)[\/\s]([2-3]\.[\d\.]+)/i],[a,c],[/rv\:([\w\.]+).*(gecko)/i],[c,a]],os:[[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],[a,[c,v.string,m.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[a,"Windows"],[c,v.string,m.os.windows.version]],[/\((bb)(10);/i],[[a,"BlackBerry"],c],[/(blackberry)\w*\/?([\w\.]+)*/i,/(tizen)\/([\w\.]+)/i,/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i],[a,c],[/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i],[[a,"Symbian"],c],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[a,"Firefox OS"],c],[/(nintendo|playstation)\s([wids3portablev]+)/i,/(mint)[\/\s\(]?(\w+)*/i,/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,/(hurd|linux)\s?([\w\.]+)*/i,/(gnu)\s?([\w\.]+)*/i],[a,c],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[a,"Chromium OS"],c],[/(sunos)\s?([\w\.]+\d)*/i],[[a,"Solaris"],c],[/\s(\w*bsd|dragonfly)\s?([\w\.]+)*/i],[a,c],[/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i],[[a,"iOS"],[c,/_/g,"."]],[/(mac\sos\sx)\s?([\w\s\.]+\w)*/i],[a,[c,/_/g,"."]],[/(haiku)\s(\w+)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i,/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,/(unix)\s?([\w\.]+)*/i],[a,c]]},y=function w(t){var r=t||(e&&e.navigator&&e.navigator.userAgent?e.navigator.userAgent:n);if(!(this instanceof w))return(new w(t)).getResult();this.getBrowser=function(){return v.regex.apply(this,g.browser)},this.getDevice=function(){return v.regex.apply(this,g.device)},this.getEngine=function(){return v.regex.apply(this,g.engine)},this.getOS=function(){return v.regex.apply(this,g.os)},this.getResult=function(){return{browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice()}},this.getUA=function(){return r},this.setUA=function(e){return r=e,this},this.setUA(r)};if(typeof exports!==i&&!/\[object\s[DOM]*Window\]/.test(global.toString()))typeof module!==i&&module.exports&&(exports=module.exports=y),exports.UAParser=y;else if(typeof define===r&&define.amd)define(function(){return y});else{e.UAParser=y;if(typeof e.jQuery!==i){var b=new y;e.jQuery.ua=b.getResult(),e.jQuery.ua.get=function(){return b.getUA()},e.jQuery.ua.set=function(t){b.setUA(t);var n=b.getResult();for(var r in n)e.jQuery.ua[r]=n[r]}}}})(this); | ||
(function(e,t){"use strict";var n="",r="?",i="function",s="undefined",o="object",u="major",a="model",f="name",l="type",c="vendor",h="version",p="console",d="mobile",v="tablet",m={has:function(e,t){return t.toLowerCase().indexOf(e.toLowerCase())!==-1},is:function(e,t){return typeof e===t}},g={rgx:function(){for(var e,n=0,r,u,a,f,l,c,h=arguments;n<h.length;n+=2){var p=h[n],d=h[n+1];if(m.is(e,s)){e={};for(a in d)f=d[a],m.is(f,o)?e[f[0]]=t:e[f]=t}for(r=u=0;r<p.length;r++){l=p[r].exec(this.getUA());if(!!l){for(a in d)c=l[++u],f=d[a],m.is(f,o)?f.length==2?e[f[0]]=f[1]:f.length==3&&(m.is(f[1],i)&&(!f[1].exec||!f[1].test)?e[f[0]]=c?f[1].call(this,c,f[2]):t:e[f[0]]=c?c.replace(f[1],f[2]):t):e[f]=c?c:t;break}}if(!!l)break}return e},str:function(e,n){for(var i in n)if(m.is(n[i],o)&&n[i].length>0){for(var s in n[i])if(m.has(n[i][s],e))return i===r?t:i}else if(m.has(n[i],e))return i===r?t:i;return e}},y={browser:{oldsafari:{major:{1:["/8","/1","/3"],2:"/4","?":"/"},version:{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}}},device:{sprint:{model:{"Evo Shift 4G":"7373KT"},vendor:{HTC:"APA",Sprint:"Sprint"}}},os:{windows:{version:{ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",RT:"ARM"}}}},b={browser:[[/(opera\smini)\/((\d+)?[\w\.-]+)/i,/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i,/(opera).+version\/((\d+)?[\w\.]+)/i,/(opera)[\/\s]+((\d+)?[\w\.]+)/i],[f,h,u],[/\s(opr)\/((\d+)?[\w\.]+)/i],[[f,"Opera"],h,u],[/(kindle)\/((\d+)?[\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,/(avant\s|iemobile|slim|baidu)(?:browser)?[\/\s]?((\d+)?[\w\.]*)/i,/ms(ie)\s((\d+)?[\w\.]+)/i,/(rekonq)((?:\/)[\w\.]+)*/i,/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i],[f,h,u],[/(yabrowser)\/((\d+)?[\w\.]+)/i],[[f,"Yandex"],h,u],[/(comodo_dragon)\/((\d+)?[\w\.]+)/i],[[f,/_/g," "],h,u],[/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i],[f,h,u],[/(dolfin)\/((\d+)?[\w\.]+)/i],[[f,"Dolphin"],h,u],[/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i],[[f,"Chrome"],h,u],[/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i],[h,u,[f,"Mobile Safari"]],[/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i],[h,u,f],[/webkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i],[f,[u,g.str,y.browser.oldsafari.major],[h,g.str,y.browser.oldsafari.version]],[/(konqueror)\/((\d+)?[\w\.]+)/i,/(webkit|khtml)\/((\d+)?[\w\.]+)/i],[f,h,u],[/(navigator|netscape)\/((\d+)?[\w\.-]+)/i],[[f,"Netscape"],h,u],[/(swiftfox)/i,/(iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i,/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?((\d+)?[\w\.]+)/i,/(links)\s\(((\d+)?[\w\.]+)/i,/(gobrowser)\/?((\d+)?[\w\.]+)*/i,/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i,/(mosaic)[\/\s]((\d+)?[\w\.]+)/i],[f,h,u]],device:[[/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i],[a,c,[l,v]],[/(hp).+(touchpad)/i,/(kindle)\/([\w\.]+)/i,/\s(nook)[\w\s]+build\/(\w+)/i,/(dell)\s(strea[kpr\s\d]*[\dko])/i],[c,a,[l,v]],[/\((ip[honed]+);.+(apple)/i],[a,c,[l,d]],[/(blackberry)[\s-]?(\w+)/i,/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola)[\s_-]?([\w-]+)*/i,/(hp)\s([\w\s]+\w)/i,/(asus)-?(\w+)/i],[c,a,[l,d]],[/\((bb10);\s(\w+)/i],[[c,"BlackBerry"],a,[l,d]],[/android.+((transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+))/i],[[c,"Asus"],a,[l,v]],[/(sony)\s(tablet\s[ps])/i],[c,a,[l,v]],[/(nintendo)\s([wids3u]+)/i],[c,a,[l,p]],[/((playstation)\s[3portablevi]+)/i],[[c,"Sony"],a,[l,p]],[/(sprint\s(\w+))/i],[[c,g.str,y.device.sprint.vendor],[a,g.str,y.device.sprint.model],[l,d]],[/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i,/(zte)-(\w+)*/i,/(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|;\ssony)[_\s-]?([\w-]+)*/i],[c,[a,/_/g," "],[l,d]],[/\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i,/(mot)[\s-]?(\w+)*/i],[[c,"Motorola"],a,[l,d]],[/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i],[[c,"Motorola"],a,[l,v]],[/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n8000|sgh-t8[56]9))/i],[[c,"Samsung"],a,[l,v]],[/((s[cgp]h-\w+|gt-\w+|galaxy\snexus))/i,/(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i,/sec-((sgh\w+))/i],[[c,"Samsung"],a,[l,d]],[/(sie)-(\w+)*/i],[[c,"Siemens"],a,[l,d]],[/(maemo|nokia).*(n900|lumia\s\d+)/i,/(nokia)[\s_-]?([\w-]+)*/i],[[c,"Nokia"],a,[l,d]],[/android\s3\.[\s\w-;]{10}((a\d{3}))/i],[[c,"Acer"],a,[l,v]],[/android\s3\.[\s\w-;]{10}(lg?)-([06cv9]{3,4})/i],[[c,"LG"],a,[l,v]],[/(lg)[e;\s-\/]+(\w+)*/i],[[c,"LG"],a,[l,d]],[/(mobile|tablet);.+rv\:.+gecko\//i],[l,c,a]],engine:[[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i,/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i,/(icab)[\/\s]([23]\.[\d\.]+)/i],[f,h],[/rv\:([\w\.]+).*(gecko)/i],[h,f]],os:[[/(windows)\snt\s6\.2;\s(arm)/i,/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i],[f,[h,g.str,y.os.windows.version]],[/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i],[[f,"Windows"],[h,g.str,y.os.windows.version]],[/\((bb)(10);/i],[[f,"BlackBerry"],h],[/(blackberry)\w*\/?([\w\.]+)*/i,/(tizen)\/([\w\.]+)/i,/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i],[f,h],[/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i],[[f,"Symbian"],h],[/mozilla.+\(mobile;.+gecko.+firefox/i],[[f,"Firefox OS"],h],[/(nintendo|playstation)\s([wids3portablevu]+)/i,/(mint)[\/\s\(]?(\w+)*/i,/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,/(hurd|linux)\s?([\w\.]+)*/i,/(gnu)\s?([\w\.]+)*/i],[f,h],[/(cros)\s[\w]+\s([\w\.]+\w)/i],[[f,"Chromium OS"],h],[/(sunos)\s?([\w\.]+\d)*/i],[[f,"Solaris"],h],[/\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i],[f,h],[/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i],[[f,"iOS"],[h,/_/g,"."]],[/(mac\sos\sx)\s?([\w\s\.]+\w)*/i],[f,[h,/_/g,"."]],[/(haiku)\s(\w+)/i,/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i,/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos)/i,/(unix)\s?([\w\.]+)*/i],[f,h]]},w=function(t){var r=t||(e&&e.navigator&&e.navigator.userAgent?e.navigator.userAgent:n);if(!(this instanceof w))return(new w(t)).getResult();this.getBrowser=function(){return g.rgx.apply(this,b.browser)},this.getDevice=function(){return g.rgx.apply(this,b.device)},this.getEngine=function(){return g.rgx.apply(this,b.engine)},this.getOS=function(){return g.rgx.apply(this,b.os)},this.getResult=function(){return{browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice()}},this.getUA=function(){return r},this.setUA=function(e){return r=e,this},this.setUA(r)};if(!m.is(exports,s))!m.is(module,s)&&module.exports&&(exports=module.exports=w),exports.UAParser=w;else if(m.is(define,i)&&define.amd)define(function(){return w});else{e.UAParser=w;if(!m.is(e.jQuery,s)){var E=e.jQuery,S=new w;E.ua=S.getResult(),E.ua.get=function(){return S.getUA()},E.ua.set=function(e){S.setUA(e);var t=S.getResult();for(var n in t)E.ua[n]=t[n]}}}})(this); |
{ | ||
"title": "UA-Parser.JS", | ||
"name": "ua-parser-js", | ||
"version": "0.5.20", | ||
"version": "0.5.22", | ||
"description": "Lightweight JavaScript-based user-agent string parser", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
75574
1787
245
0