Compare commits

...

22 Commits
0.7.7 ... 0.7.9

Author SHA1 Message Date
Faisal Salman
992e829643 Verup 0.7.9 2015-07-19 04:00:01 +07:00
Faisal Salman
e9e5467add Readme: flattr button, nodejs example, drop browser.major 2015-07-19 03:49:39 +07:00
Faisal Salman
d3a2e1750b Merge branch 'master' of github.com:faisalman/ua-parser-js 2015-07-19 02:22:22 +07:00
Faisal Salman
29d75c994e Merge pull request #124 from longsleep/iridium-detection
Added detection for Iridium Browser.
2015-07-19 02:23:38 +07:00
Faisal Salman
7e23d53e4b Merge branch 'master' of github.com:faisalman/ua-parser-js 2015-07-19 02:03:50 +07:00
Simon Eisenmann
892476f544 Added detection for Iridium Browser. 2015-07-17 16:10:59 +02:00
Faisal Salman
a165e152de Merge pull request #119 from roberttod/patch-1
Reference window as global if available
2015-07-04 01:39:19 +07:00
Faisal Salman
ab64c21a80 Merge pull request #120 from demis-palma/patch-4
palm os regexp fixed
2015-07-04 01:39:14 +07:00
Faisal Salman
5da2305369 Merge pull request #121 from duzun/verup
verup.js installed over NPM -> devDependencies
2015-07-04 01:39:10 +07:00
Dumitru Uzun
1b957cad1a verup.js installed over NPM -> devDependencies 2015-06-19 01:50:06 +03:00
Demis Palma
8d9cd21331 palm os regexp fixed
The regexp won't work as expected because the meta-character \o doesn't make sense.
Replaced with \s which indicates "whitespace character"
2015-06-18 23:32:15 +01:00
Robert Tod
f117f600ba Reference window as global if available
This change will use `window` by default if it exists so that `browserify` and `Webpack` builds do not need to do something like

```javascript
var parser = new UAParser(window.navigator.userAgent)
```

https://github.com/faisalman/ua-parser-js/issues/84
2015-06-10 17:35:16 +01:00
Faisal Salman
978ee5a4da Add Firefox for iOS 2015-05-11 23:33:57 +07:00
Faisal Salman
a3e4fbe5bb Merge pull request #116 from nikrolls/patch-1
Added Edge and EdgeHTML to documentation
2015-05-10 12:14:13 +07:00
Faisal Salman
9dacf37e4a Merge pull request #112 from duzun/master
Updated verup to v1.2.0 and moved its config to package.json
2015-05-10 12:13:46 +07:00
Nik Rolls
4d99bc0777 Added Edge and EdgeHTML to documentation 2015-05-10 15:33:36 +12:00
Faisal Salman
f558e657bb Merge pull request #113 from nikrolls/correct-ms-edge-detection
Microsoft Edge is not IE12
2015-05-08 20:15:13 +07:00
Nik Rolls
4203f8144f Microsoft Edge is not IE12 2015-05-08 18:02:05 +12:00
Faisal Salman
21a525f442 Add layout engine: EdgeHTML 2015-05-07 04:59:01 +07:00
Faisal Salman
3abf465aec changing build flow 2015-05-07 04:21:43 +07:00
Dumitru Uzun
56c90d2134 updated verup script 2015-05-05 20:39:23 +03:00
Dumitru Uzun
dc6bae6aae Updated verup to v1.2.0 and moved its config to package.json 2015-04-30 17:58:30 +03:00
13 changed files with 109 additions and 204 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "ua-parser-js",
"version": "0.7.7",
"version": "0.7.9",
"authors": [
"Faisal Salman <fyzlman@gmail.com>"
],

View File

@@ -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 > dist/ua-parser.min.js --comments '/UAParser\.js/'
echo "OK"

View File

@@ -1,112 +0,0 @@
#!/usr/bin/env node
/**
* Increment and update version in all project files.
*
* Ussage:
*
* Increment revision by 1:
* node verup.js 1
*
* Increment minor version by 1:
* node verup.js 1.0
*
* Increment major version by 1:
* node verup.js 1.0.0
*
*
* @author Dumitru Uzun (DUzun.Me)
* @version 1.1.0
*/
var path = require('path');
var fs = require('fs');
var _root = path.join(__dirname, '..');
var files = [
'ua-parser-js.jquery.json',
'component.json',
'bower.json',
'package.js',
'src/ua-parser.js'
];
var ver_reg = [
/^((?:\$|@|(\s*(?:var|,)?\s+))(?:LIBVERSION|version)[\s\:='"]+)([0-9]+(?:\.[0-9]+){2,2})/
, /^(\s?\*.*v)([0-9]+(?:\.[0-9]+){2,2})/
];
var packFile = path.join(_root, 'package.json');
var packo = require(packFile);
if ( !packo ) {
console.error('Can\'t read package.json file');
process.exit(1);
}
var over = packo.version;
/*
* bump should be 1 for revision, 1.0 for minor and 1.0.0 for major version
*/
var bump = (process.argv[2] || '1').split('.').reverse();
if ( over ) {
var nver = over.split('.').reverse();
var b, l;
while(bump.length && !(b = parseInt(bump.pop())));
l = bump.length;
// console.log({b:b,nver:nver,over:over,l:l,bump:bump})
nver[l] = +nver[l] + b;
bump.forEach(function (v,i) { nver[i] = v; });
nver = nver.reverse().join('.');
packo.version = nver;
console.log('Bumping version: ' + over + ' -> ' + nver);
var buf = JSON.stringify(packo, null, 2);
if ( buf && over != nver ) {
buf += "\n";
fs.writeFileSync(packFile, buf);
}
files.forEach(function (f) {
var fn = path.join(_root, f);
var cnt = fs.readFileSync(fn, 'utf8');
var ext = path.extname(f);
var buf;
switch(ext) {
case '.json': {
var packo = JSON.parse(cnt);
packo.version = nver;
buf = JSON.stringify(packo, null, 2);
if ( buf ) {
buf += "\n";
}
} break;
default: {
buf = cnt
.split('\n')
.map(function (l) {
for(var i=ver_reg.length; i--;) {
if ( ver_reg[i].test(l) ) {
return l.replace(ver_reg[i], function ($0,$1) { return $1 + nver })
}
}
return l;
})
.join("\n")
;
}
}
if ( buf && buf != cnt ) {
console.log("\t" + fn.replace(_root, ''));
fs.writeFileSync(fn, buf);
}
});
}

View File

@@ -1,6 +1,6 @@
{
"name": "ua-parser-js",
"version": "0.7.7",
"version": "0.7.9",
"description": "Lightweight JavaScript-based user-agent string parser",
"keywords": [
"user-agent",

File diff suppressed because one or more lines are too long

9
dist/ua-parser.pack.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'faisalman:ua-parser-js',
version: '0.7.7',
version: '0.7.9',
summary: 'Lightweight JavaScript-based user-agent string parser',
git: 'https://github.com/faisalman/ua-parser-js.git',
documentation: 'readme.md'

View File

@@ -1,7 +1,7 @@
{
"title": "UAParser.js",
"name": "ua-parser-js",
"version": "0.7.7",
"version": "0.7.9",
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
"description": "Lightweight JavaScript-based user-agent string parser",
"keywords": [
@@ -42,13 +42,29 @@
],
"main": "src/ua-parser.js",
"scripts": {
"test": "./build/build.sh",
"verup": "node ./build/verup.js"
"build": "uglifyjs src/ua-parser.js > dist/ua-parser.min.js --comments '/UAParser\\.js/' && uglifyjs src/ua-parser.js > 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": [
"ua-parser-js.jquery.json",
"component.json",
"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.8.0",
"uglify-js": "~1.3.4"
"uglify-js": "~1.3.4",
"verup": "^1.3.x"
},
"repository": {
"type": "git",

View File

@@ -1,8 +1,9 @@
# UAParser.js
Lightweight JavaScript-based User-Agent string parser. Supports browser & node.js environment. Also available as jQuery/Zepto plugin, Component package, Bower package, Meteor package, & AMD module
Lightweight JavaScript-based User-Agent string parser. Supports browser & node.js environment. Also available as jQuery/Zepto plugin, Component/Bower/Meteor package, & RequireJS/AMD module
[![Build Status](https://travis-ci.org/faisalman/ua-parser-js.svg?branch=master)](https://travis-ci.org/faisalman/ua-parser-js)
[![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/3867907/faisalmanua-parser-js-on-GitHub)
* Author : Faisal Salman <<fyzlman@gmail.com>>
* Demo : http://faisalman.github.io/ua-parser-js
@@ -17,20 +18,20 @@ Extract detailed type of web browser, layout engine, operating system, cpu archi
## Methods
* `getBrowser()`
* returns `{ name: '', major: '', version: '' }`
* returns `{ name: '', version: '' }`
```
# Possible 'browser.name':
Amaya, Android Browser, 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,
Chromium, Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Edge, Epiphany, Fennec,
Firebird, Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, IceCat, IceDragon,
Iceweasel, IE [Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle, Links,
Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, MIUI Browser, [Mobile] Safari,
Mosaic, Mozilla, Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet],
Phoenix, Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, SlimBrowser, Swiftfox,
Tizen, UCBrowser, Vivaldi, w3m, Yandex
# 'browser.version' & 'browser.major' determined dynamically
# 'browser.version' determined dynamically
```
* `getDevice()`
@@ -54,8 +55,8 @@ Siemens, Sony-Ericsson, Sprint, Xbox, ZTE
```
# Possible 'engine.name'
Amaya, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto, Tasman,
Trident, w3m, WebKit
Amaya, EdgeHTML, Gecko, iCab, KHTML, Links, Lynx, NetFront, NetSurf, Presto,
Tasman, Trident, w3m, WebKit
# 'engine.version' determined dynamically
```
@@ -112,8 +113,7 @@ ppc, sparc, sparc64
ua: "",
browser: {
name: "",
version: "",
major: ""
version: ""
},
engine: {
name: "",
@@ -142,7 +142,7 @@ ppc, sparc, sparc64
// 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"
@@ -167,20 +167,6 @@ ppc, sparc, sparc64
</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
```sh
@@ -188,10 +174,18 @@ $ 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
@@ -209,12 +203,6 @@ require(['ua-parser'], function(UAParser) {
$ component install faisalman/ua-parser-js
```
```js
var UAParser = require('ua-parser-js');
var parser = new UAParser();
console.log(parser.getResult());
```
### Using bower
```sh
@@ -250,12 +238,27 @@ console.log($.ua.device); // {vendor: "Motorola", model: "Xoom", type:
console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
```
### 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)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]];
var parser = new UAParser(uaString, {browser: ownBrowser});
console.log(parser.getBrowser()); // {name: "ownbrowser", version: "1.3"}
```
## Development
Verify, test, & minify script
```sh
$ npm test
$ npm run test
$ npm run build
```
Then submit a pull request to https://github.com/faisalman/ua-parser-js under `develop` branch.

View File

@@ -1,5 +1,5 @@
/**
* UAParser.js v0.7.7
* UAParser.js v0.7.9
* Lightweight JavaScript-based User-Agent string parser
* https://github.com/faisalman/ua-parser-js
*
@@ -16,7 +16,7 @@
/////////////
var LIBVERSION = '0.7.7',
var LIBVERSION = '0.7.9',
EMPTY = '',
UNKNOWN = '?',
FUNC_TYPE = 'function',
@@ -249,14 +249,16 @@
// Webkit/KHTML based
/(rekonq)\/([\w\.]+)*/i, // Rekonq
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi)\/([\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium)\/([\w\.-]+)/i
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium
], [NAME, VERSION], [
/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i, // IE11
/(Edge)\/((\d+)?[\w\.]+)/i // IE12
/(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
], [[NAME, 'IE'], VERSION], [
/(edge)\/((\d+)?[\w\.]+)/i // Microsoft Edge
], [NAME, VERSION], [
/(yabrowser)\/([\w\.]+)/i // Yandex
], [[NAME, 'Yandex'], VERSION], [
@@ -300,6 +302,8 @@
// Gecko based
/(navigator|netscape)\/([\w\.-]+)/i // Netscape
], [[NAME, 'Netscape'], VERSION], [
/fxios\/([\w\.-]+)/i // Firefox for iOS
], [VERSION, [NAME, 'Firefox']], [
/(swiftfox)/i, // Swiftfox
/(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,
// IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
@@ -653,6 +657,9 @@
engine : [[
/windows.+\sedge\/([\w\.]+)/i // EdgeHTML
], [VERSION, [NAME, 'EdgeHTML']], [
/(presto)\/([\w\.]+)/i, // Presto
/(webkit|trident|netfront|netsurf|amaya|lynx|w3m)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m
/(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
@@ -679,7 +686,7 @@
], [[NAME, 'BlackBerry'], VERSION], [
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
/(tizen)[\/\s]([\w\.]+)/i, // Tizen
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i,
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki
/linux;.+(sailfish);/i // Sailfish OS
], [NAME, VERSION], [
@@ -860,4 +867,4 @@
};
}
})(this);
})(typeof window === 'object' ? window : this);

View File

@@ -690,13 +690,23 @@
}
},
{
"desc" : "Windows 10 EI",
"desc" : "Microsoft Edge",
"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" : "IE",
"name" : "Edge",
"version" : "12.0",
"major" : "12"
}
},
{
"desc" : "Iridium",
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Iridium/43.8 Safari/537.36 Chrome/43.0.2357.132",
"expect" :
{
"name" : "Iridium",
"version" : "43.8",
"major" : "43"
}
}
]

View File

@@ -1,4 +1,13 @@
[
{
"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",

View File

@@ -1,7 +1,7 @@
{
"title": "UAParser.js",
"name": "ua-parser-js",
"version": "0.7.7",
"version": "0.7.9",
"description": "Lightweight JavaScript-based user-agent string parser",
"keywords": [
"user-agent",