Compare commits

..

13 Commits

Author SHA1 Message Date
Faisal Salman
80d6d137ba Increment build version 2013-07-04 17:49:34 +07:00
Faisal Salman
19b5ddd038 Fix rv token IE11 2013-07-04 17:44:05 +07:00
Faisal Salman
9133d73d50 Merge branch 'ie11' of github.com:faisalman/ua-parser-js 2013-07-04 17:40:44 +07:00
Faisal Salman
3699c70a3a Fix unicode char 2013-07-04 17:39:48 +07:00
Faisal Salman
e6d276032b Motorola droid test case 2013-07-04 16:46:42 +07:00
Faisal Salman
b68caafd94 New test for IE11 2013-07-04 16:37:05 +07:00
Faisal Salman
eed632e3dd Detect IE11 without MSIE token 2013-07-04 15:53:46 +07:00
Faisal Salman
c5ce73f7de Add browsers: Iron, IceDragon, QQBrowser 2013-06-24 19:43:07 +07:00
Faisal Salman
2c9c721a5c Motorola Droid lineup 2013-06-13 13:57:24 +07:00
Faisal Salman
ec50c619ea Merge pull request #17 from silkapp/master
Fix problem with html5shiv and old IE
2013-05-19 22:01:37 -07:00
Erik Hesselink
07a7956eda Change 'for..in' loop to for loop.
The 'for..in' loop caused problems when the array was extended with
more methods (like map), e.g. by html5shiv in old IEs.
2013-05-17 14:05:21 +02:00
Faisal Salman
be0eec6716 Include ua in result object 2013-04-04 14:50:46 +07:00
Faisal Salman
8d439d26b8 Fix PocketPC mistakenly identified as PowerPC 2013-04-04 14:35:02 +07:00
9 changed files with 67 additions and 32 deletions

View File

@@ -1,8 +1,8 @@
{ {
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "0.6.0", "version": "0.6.2",
"description": "Lightweight JavaScript-based user-agent string parser", "description": "Lightweight JavaScript-based user-agent string parser",
"keywords": ["user-agent", "parser", "browser", "engine", "os", "device"], "keywords": ["user-agent", "parser", "browser", "engine", "os", "device", "cpu"],
"scripts": ["src/ua-parser.js"], "scripts": ["src/ua-parser.js"],
"main": "src/ua-parser.js", "main": "src/ua-parser.js",
"license": "MIT", "license": "MIT",

View File

@@ -1,7 +1,7 @@
{ {
"title": "UAParser.js", "title": "UAParser.js",
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "0.6.0", "version": "0.6.2",
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)", "author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
"description": "Lightweight JavaScript-based user-agent string parser", "description": "Lightweight JavaScript-based user-agent string parser",
"keywords": [ "keywords": [
@@ -10,7 +10,8 @@
"browser", "browser",
"engine", "engine",
"os", "os",
"device" "device",
"cpu"
], ],
"homepage": "http://github.com/faisalman/ua-parser-js", "homepage": "http://github.com/faisalman/ua-parser-js",
"contributors": [ "contributors": [

View File

@@ -10,7 +10,7 @@ Lightweight JavaScript-based User-Agent string parser. Supports browser & node.j
## Features ## Features
Extract detailed type of web browser, layout engine, operating system, and device purely from user-agent string with relatively lightweight footprint (~7KB minified / ~3KB gzipped). Written in vanilla js, which means it doesn't depends on any other library. Extract detailed type of web browser, layout engine, operating system, cpu architecture, and device purely from user-agent string with relatively lightweight footprint (~7KB minified / ~3KB gzipped). Written in vanilla js, which means it doesn't depends on any other library.
![It's over 9000](https://pbs.twimg.com/media/A9LpEG6CIAA5VrT.jpg) ![It's over 9000](https://pbs.twimg.com/media/A9LpEG6CIAA5VrT.jpg)
@@ -23,11 +23,12 @@ Extract detailed type of web browser, layout engine, operating system, and devic
# Possible 'browser.name': # Possible 'browser.name':
Amaya, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome, Chromium, Amaya, Arora, Avant, Baidu, Blazer, Bolt, Camino, Chimera, Chrome, Chromium,
Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Epiphany, Fennec, Firebird, Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Epiphany, Fennec, Firebird,
Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, Iceweasel, Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, IceDragon,
IE [Mobile], Jasmine, K-Meleon, Konqueror, Kindle, Links, Lunascape, Lynx, Maemo, Iceweasel, IE [Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle, Links,
Maxthon, Midori, Minimo, [Mobile] Safari, Mosaic, Mozilla, Netfront, Netscape, Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, [Mobile] Safari, Mosaic, Mozilla,
NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet], Phoenix, Polaris, RockMelt, Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet], Phoenix,
Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox, Tizen, UCBrowser, w3m, Yandex Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox,
Tizen, UCBrowser, w3m, Yandex
# 'browser.version' & 'browser.major' determined dynamically # 'browser.version' & 'browser.major' determined dynamically
``` ```
@@ -78,11 +79,11 @@ Windows [Phone/Mobile], Zenwalk
``` ```
# Possible 'cpu.architecture' # Possible 'cpu.architecture'
68k, amd64, arm, ia32, ia64, irix, mips, pa-risc, ppc, sparc 68k, amd64, arm, ia32, ia64, irix, irix64, mips, mips64, pa-risc, ppc, sparc, sparc64
``` ```
* `getResult()` * `getResult()`
* returns `{ browser: {}, cpu: {}, device: {}, engine: {}, os: {} }` * returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
* `getUA()` * `getUA()`
* returns UA string of current instance * returns UA string of current instance
* `setUA(uastring)` * `setUA(uastring)`
@@ -104,6 +105,7 @@ Windows [Phone/Mobile], Zenwalk
/* /*
/// this will print an object structured like this: /// this will print an object structured like this:
{ {
ua: "",
browser: { browser: {
name: "", name: "",
version: "", version: "",

View File

@@ -1,4 +1,4 @@
// UAParser.js v0.6.0 // UAParser.js v0.6.2
// Lightweight JavaScript-based User-Agent string parser // Lightweight JavaScript-based User-Agent string parser
// https://github.com/faisalman/ua-parser-js // https://github.com/faisalman/ua-parser-js
// //
@@ -121,7 +121,7 @@
for (var i in map) { for (var i in map) {
// check if array // check if array
if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) { if (typeof(map[i]) === OBJ_TYPE && map[i].length > 0) {
for (var j in map[i]) { for (var j = 0; j < map[i].length; j++) {
if (util.has(map[i][j], str)) { if (util.has(map[i][j], str)) {
return (i === UNKNOWN) ? undefined : i; return (i === UNKNOWN) ? undefined : i;
} }
@@ -224,10 +224,13 @@
// Webkit/KHTML based // Webkit/KHTML based
/(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq /(rekonq)((?:\/)[\w\.]+)*/i, // Rekonq
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron)\/((\d+)?[\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron
], [NAME, VERSION, MAJOR], [ ], [NAME, VERSION, MAJOR], [
/(trident).+rv[:\s]((\d+)?[\w\.]+).+like\sgecko/i // IE11
], [[NAME, 'IE'], VERSION, MAJOR], [
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex /(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
], [[NAME, 'Yandex'], VERSION, MAJOR], [ ], [[NAME, 'Yandex'], VERSION, MAJOR], [
@@ -261,15 +264,15 @@
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape /(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
], [[NAME, 'Netscape'], VERSION, MAJOR], [ ], [[NAME, 'Netscape'], VERSION, MAJOR], [
/(swiftfox)/i, // Swiftfox /(swiftfox)/i, // Swiftfox
/(iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i, /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?((\d+)?[\w\.\+]+)/i,
// Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i, /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla /(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
// Other // Other
/(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?((\d+)?[\w\.]+)/i, /(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|qqbrowser)[\/\s]?((\d+)?[\w\.]+)/i,
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf // UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/QQBrowser
/(links)\s\(((\d+)?[\w\.]+)/i, // Links /(links)\s\(((\d+)?[\w\.]+)/i, // Links
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser /(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
/(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser /(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, // ICE Browser
@@ -285,6 +288,10 @@
/((?:i[346]|x)86)[;\)]/i // IA32 /((?:i[346]|x)86)[;\)]/i // IA32
], [[ARCHITECTURE, 'ia32']], [ ], [[ARCHITECTURE, 'ia32']], [
// PocketPC mistakenly identified as PowerPC
/windows\s(ce|mobile);\sppc;/i
], [[ARCHITECTURE, 'arm']], [
/((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC /((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
], [[ARCHITECTURE, /ower/, '', util.lowerize]], [ ], [[ARCHITECTURE, /ower/, '', util.lowerize]], [
@@ -340,7 +347,8 @@
// Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony // Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [ ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
/\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i, // Motorola // Motorola
/\s((milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?(:?\s4g)?))[\w\s]+build\//i,
/(mot)[\s-]?(\w+)*/i /(mot)[\s-]?(\w+)*/i
], [[VENDOR, 'Motorola'], MODEL, [TYPE, MOBILE]], [ ], [[VENDOR, 'Motorola'], MODEL, [TYPE, MOBILE]], [
/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i /android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i
@@ -475,6 +483,7 @@
}; };
this.getResult = function() { this.getResult = function() {
return { return {
ua : this.getUA(),
browser : this.getBrowser(), browser : this.getBrowser(),
engine : this.getEngine(), engine : this.getEngine(),
os : this.getOS(), os : this.getOS(),

File diff suppressed because one or more lines are too long

View File

@@ -240,7 +240,7 @@
} }
}, },
{ {
"desc" : "IE 11", "desc" : "IE 11 with IE token",
"ua" : "Mozilla/5.0 (IE 11.0; Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko", "ua" : "Mozilla/5.0 (IE 11.0; Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko",
"expect" : "expect" :
{ {
@@ -249,6 +249,16 @@
"major" : "11" "major" : "11"
} }
}, },
{
"desc" : "IE 11 without IE token",
"ua" : "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko",
"expect" :
{
"name" : "IE",
"version" : "11.0",
"major" : "11"
}
},
{ {
"desc" : "K-Meleon", "desc" : "K-Meleon",
"ua" : "Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031016 K-Meleon/0.8.2", "ua" : "Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.5) Gecko/20031016 K-Meleon/0.8.2",

View File

@@ -47,6 +47,14 @@
"architecture" : "arm" "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", "desc" : "Mac PowerPC",
"ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)", "ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)",

View File

@@ -18,4 +18,14 @@
"model" : "Nexus 4", "model" : "Nexus 4",
"type" : "mobile" "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"
}
}] }]

View File

@@ -1,7 +1,7 @@
{ {
"title": "UAParser.js", "title": "UAParser.js",
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "0.6.0", "version": "0.6.2",
"description": "Lightweight JavaScript-based user-agent string parser", "description": "Lightweight JavaScript-based user-agent string parser",
"keywords": [ "keywords": [
"user-agent", "user-agent",
@@ -9,7 +9,8 @@
"browser", "browser",
"engine", "engine",
"os", "os",
"device" "device",
"cpu"
], ],
"homepage": "https://faisalman.github.com/ua-parser-js", "homepage": "https://faisalman.github.com/ua-parser-js",
"author": { "author": {