Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-useragent

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-useragent - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

2

index.js

@@ -7,3 +7,3 @@ /**

* @package express-useragent
* @version 0.0.6
* @version 0.0.8
* @copyright Copyright (c) 2009-2012 - All rights reserved.

@@ -10,0 +10,0 @@ * @license MIT License

@@ -7,3 +7,3 @@ /**

* @package express-useragent
* @version 0.0.7
* @version 0.0.8
* @copyright Copyright (c) 2009-2011 - All rights reserved.

@@ -17,3 +17,3 @@ * @license MIT License

var UserAgent = function() {
this.version = '0.0.7';
this.version = '0.0.8';
this._Versions = {

@@ -26,6 +26,17 @@ Firefox: /firefox\/([\d\w\.\-]+)/i,

Ps3: /([\d\w\.\-]+)\)\s*$/i,
Psp: /([\d\w\.\-]+)\)?\s*$/i
Psp: /([\d\w\.\-]+)\)?\s*$/i,
Amaya: /amaya\/([\d\w\.\-]+)/i,
SeaMonkey: /seamonkey\/([\d\w\.\-]+)/i,
OmniWeb: /omniweb\/v([\d\w\.\-]+)/i,
Flock: /flock\/([\d\w\.\-]+)/i,
Epiphany: /epiphany\/([\d\w\.\-]+)/i
};
this._Browsers = {
Amaya: /amaya/i,
Konqueror: /konqueror/i,
Epiphany: /epiphany/i,
SeaMonkey: /seamonkey/i,
Flock: /flock/i,
OmniWeb:/omniweb/i,
Chromium: /chromium/i,
Chrome: /chrome/i,

@@ -40,4 +51,6 @@ Safari: /safari/i,

this._OS = {
Windows8: /windows nt 6\.2/i,
Windows7: /windows nt 6\.1/i,
UnknownWindows: /windows nt 6\.\d+/i,
WindowsVista: /windows nt 6\.0/i,
Windows7: /windows nt 6\.\d+/i,
Windows2003: /windows nt 5\.2/i,

@@ -47,2 +60,3 @@ WindowsXP: /windows nt 5\.1/i,

OSX: /os x (\d+)[._](\d+)/i,
Mac: /os x/i,
Linux: /linux/i,

@@ -84,2 +98,7 @@ Wii: /wii/i,

isKonqueror : false,
isOmniWeb : false,
isSeaMonkey : false,
isFlock : false,
isAmaya : false,
isEpiphany : false,
isDesktop : false,

@@ -91,2 +110,4 @@ isWindows : false,

isSamsung : false,
isRaspberry : false,
isBot : false,
Browser : 'unknown',

@@ -96,4 +117,6 @@ Version : 'unknown',

Platform : 'unknown',
GeoIP : {},
source:''
};
this.getBrowser = function(string) {

@@ -104,2 +127,20 @@ switch (true) {

return 'Konqueror';
case this._Browsers.Amaya.test(string):
this.Agent.isAmaya = true;
return 'Amaya';
case this._Browsers.Epiphany.test(string):
this.Agent.isEpiphany = true;
return 'Epiphany';
case this._Browsers.SeaMonkey.test(string):
this.Agent.isSeaMonkey = true;
return 'SeaMonkey';
case this._Browsers.Flock.test(string):
this.Agent.isFlock = true;
return 'Flock';
case this._Browsers.OmniWeb.test(string):
this.Agent.isOmniWeb = true;
return 'OmniWeb';
case this._Browsers.Chromium.test(string):
this.Agent.isChrome = true;
return 'Chromium';
case this._Browsers.Chrome.test(string):

@@ -167,2 +208,32 @@ this.Agent.isChrome = true;

break;
case 'Chromium':
if (this._Versions.Chrome.test(string)) {
return RegExp.$1;
}
break;
case 'Amaya':
if (this._Versions.Amaya.test(string)) {
return RegExp.$1;
}
break;
case 'Epiphany':
if (this._Versions.Epiphany.test(string)) {
return RegExp.$1;
}
break;
case 'SeaMonkey':
if (this._Versions.SeaMonkey.test(string)) {
return RegExp.$1;
}
break;
case 'Flock':
if (this._Versions.Flock.test(string)) {
return RegExp.$1;
}
break;
case 'OmniWeb':
if (this._Versions.OmniWeb.test(string)) {
return RegExp.$1;
}
break;
default:

@@ -184,2 +255,5 @@ regex = /#{name}[\/ ]([\d\w\.\-]+)/i;

return 'Windows 7';
case this._OS.Windows8.test(string):
this.Agent.isWindows = true;
return 'Windows 8';
case this._OS.Windows2003.test(string):

@@ -203,2 +277,5 @@ this.Agent.isWindows = true;

return 'Playstation';
case this._OS.Mac.test(string):
this.Agent.isMac = true;
return 'OS X';
case this._OS.OSX.test(string):

@@ -266,11 +343,11 @@ this.Agent.isMac = true;

switch (true) {
case this.Agent.isWindows:
case this.Agent.isLinux:
case this.Agent.isMac:
this.Agent.isDesktop = true;
case ua.Agent.isWindows:
case ua.Agent.isLinux:
case ua.Agent.isMac:
ua.Agent.isDesktop = true;
break;
case this.Agent.isAndroid:
case this.Agent.isSamsung:
this.Agent.isMobile = true;
this.Agent.isDesktop = false;
case ua.Agent.isAndroid:
case ua.Agent.isSamsung:
ua.Agent.isMobile = true;
ua.Agent.isDesktop = false;
break;

@@ -280,16 +357,35 @@ default:

switch (true) {
case this.Agent.isiPad:
case this.Agent.isiPod:
case this.Agent.isiPhone:
case this.Agent.isBada:
case this.Agent.isBlackberry:
case this.Agent.isAndroid:
this.Agent.isMobile = true;
this.Agent.isDesktop = false;
case ua.Agent.isiPad:
case ua.Agent.isiPod:
case ua.Agent.isiPhone:
case ua.Agent.isBada:
case ua.Agent.isBlackberry:
case ua.Agent.isAndroid:
ua.Agent.isMobile = true;
ua.Agent.isDesktop = false;
break;
default:
}
// console.log(this);
if(/mobile/i.test(ua.Agent.source)) {
ua.Agent.isMobile = true;
ua.Agent.isDesktop = false;
}
};
this.testNginxGeoIP = function testNginxGeoIP(headers) {
var ua = this;
Object.keys(headers).forEach(function(key){
if(/^GEOIP/i.test(key)) {
ua.Agent.GeoIP[key] = headers[key];
}
});
};
this.testBot = function testBot() {
var ua = this;
if(/googlebot|gurujibot|yandexbot|slurp|msnbot|bingbot/i.test(key)) {
ua.Agent.isBot = true;
}
};
this.parse = function parse(source) {

@@ -302,2 +398,3 @@ var ua = new UserAgent();

ua.Agent.Version = ua.getBrowserVersion(ua.Agent.source);
ua.testBot();
ua.testMobile();

@@ -317,2 +414,4 @@ return ua.Agent;

ua.Agent.Version = ua.getBrowserVersion(ua.Agent.source);
ua.testNginxGeoIP(req.headers);
ua.testBot();
ua.testMobile();

@@ -319,0 +418,0 @@ req.useragent = ua.Agent;

{
"name": "express-useragent",
"description": "ExpressJS user-agent middleware",
"version": "0.0.7",
"version": "0.0.8",
"homepage": "https://github.com/biggora/express-useragent/",

@@ -15,2 +15,3 @@ "repository": {

"express",
"trinte",
"railway",

@@ -17,0 +18,0 @@ "compound",

@@ -31,2 +31,18 @@ [![build status](https://secure.travis-ci.org/biggora/express-useragent.png)](http://travis-ci.org/biggora/express-useragent)

### for [TrinteJS](http://www.trintejs.com/)
is permanently included
#### manual setup in project config/middleware.js
```js
var useragent = require('express-useragent');
module.exports = function (app, express) {
app.configure(function () {
app.use(useragent.express());
});
};
```
### for [ExpressJS](http://expressjs.com/)

@@ -70,2 +86,3 @@

"isDesktop":true,
"isBot":false,
.....

@@ -97,2 +114,11 @@ "Browser":"Chrome",

### Recommend extensions
- [Bootstrap Fancy File Plugin](http://biggora.github.io/bootstrap-fancyfile/)
- [Bootstrap Ajax Typeahead Plugin](https://github.com/biggora/bootstrap-ajax-typeahead)
- [TrinteJS - Javascrpt MVC Framework for Node.JS](http://www.trintejs.com/)
- [CaminteJS - Cross-db ORM for NodeJS](http://www.camintejs.com/)
- [MongoDB Session Storage for ExpressJS](https://github.com/biggora/express-mongodb)
- [2CO NodeJS adapter for 2checkout API payment gateway](https://github.com/biggora/2co)
### Startups & Apps

@@ -102,4 +128,5 @@

- [GorkaTV](https://gorkatv.com/)
- [TrinteJS](http://www.trintejs.com/)
- [CaminteJS](http://www.camintejs.com/)
## Author

@@ -106,0 +133,0 @@

@@ -14,3 +14,3 @@ /**

test.ok(a.isMobile, 'Mobile'); // XXX neither mobile neither desktop
test.ok(a.isMobile, 'Mobile');
test.ok(a.isiPad, 'iPad');

@@ -28,6 +28,6 @@ test.ok(!a.isiPod, 'iPod');

test.ok(!a.isKonqueror, 'Konqueror');
test.ok(!a.isDesktop, 'Desktop'); // XXX neither mobile neither desktop
test.ok(!a.isDesktop, 'Desktop');
test.ok(!a.isWindows, 'Windows');
test.ok(!a.isLinux, 'Linux');
test.ok(!a.isMac, 'Mac');
test.ok(a.isMac, 'Mac');
test.equal(a.Version, '5.1');

@@ -124,3 +124,3 @@

exports['Linux Ephiphany'] = function(test) {
exports['Linux Ephiphany 2.30'] = function(test) {

@@ -140,3 +140,4 @@ var s = 'Mozilla/5.0 (X11; U; Linux i686; en-us) AppleWebKit/531.2+ (KHTML, like Gecko)'

test.ok(!a.isIE, 'IE');
test.ok(a.isSafari, 'Safari'); // XXX not really safari?
test.ok(!a.isSafari, 'Safari');
test.ok(a.isEpiphany, 'Epiphany');
test.ok(!a.isFirefox, 'Firefox');

@@ -150,3 +151,3 @@ test.ok(!a.isWebkit, 'Webkit');

test.ok(!a.isMac, 'Mac');
test.equal(a.Version, '5.0'); // XXX not really the correct version?
test.equal(a.Version, '2.30.6');

@@ -156,2 +157,60 @@ test.done();

exports['Windows 8 Chrome 28'] = function(test) {
var s = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36';
var a = ua.parse(s);
test.ok(!a.isMobile, 'Mobile');
test.ok(!a.isiPad, 'iPad');
test.ok(!a.isiPod, 'iPod');
test.ok(!a.isiPhone, 'iPhone');
test.ok(!a.isAndroid, 'Android');
test.ok(!a.isBlackberry, 'Blackberry');
test.ok(!a.isOpera, 'Opera');
test.ok(!a.isIE, 'IE');
test.ok(!a.isSafari, 'Safari');
test.ok(!a.isFirefox, 'Firefox');
test.ok(!a.isWebkit, 'Webkit');
test.ok(a.isChrome, 'Chrome');
test.ok(!a.isKonqueror, 'Konqueror');
test.ok(a.isDesktop, 'Desktop');
test.ok(a.isWindows, 'Windows');
test.ok(!a.isLinux, 'Linux');
test.ok(!a.isMac, 'Mac');
test.equal(a.Version, '28.0.1500.95');
test.equal(a.OS, 'Windows 8');
test.done();
};
exports['Windows 7 Firefox 23'] = function(test) {
var s = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0';
var a = ua.parse(s);
test.ok(!a.isMobile, 'Mobile');
test.ok(!a.isiPad, 'iPad');
test.ok(!a.isiPod, 'iPod');
test.ok(!a.isiPhone, 'iPhone');
test.ok(!a.isAndroid, 'Android');
test.ok(!a.isBlackberry, 'Blackberry');
test.ok(!a.isOpera, 'Opera');
test.ok(!a.isIE, 'IE');
test.ok(!a.isSafari, 'Safari');
test.ok(a.isFirefox, 'Firefox');
test.ok(!a.isWebkit, 'Webkit');
test.ok(!a.isChrome, 'Chrome');
test.ok(!a.isKonqueror, 'Konqueror');
test.ok(a.isDesktop, 'Desktop');
test.ok(a.isWindows, 'Windows');
test.ok(!a.isLinux, 'Linux');
test.ok(!a.isMac, 'Mac');
test.equal(a.Version, '23.0');
test.equal(a.OS, 'Windows 7');
test.done();
};
exports['Windows XP IE 5.5'] = function(test) {

@@ -327,6 +386,35 @@

//
exports['OS X Safari'] = function(test) {
exports['OS X OmniWeb 622'] = function(test) {
var s = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US) AppleWebKit/528.16'
+ '(KHTML, like Gecko, Safari/528.16) OmniWeb/v622.8.0.112941';
var a = ua.parse(s);
test.ok(!a.isMobile, 'Mobile');
test.ok(!a.isiPad, 'iPad');
test.ok(!a.isiPod, 'iPod');
test.ok(!a.isiPhone, 'iPhone');
test.ok(!a.isAndroid, 'Android');
test.ok(!a.isBlackberry, 'Blackberry');
test.ok(!a.isOpera, 'Opera');
test.ok(!a.isIE, 'IE');
test.ok(!a.isSafari, 'Safari');
test.ok(a.isOmniWeb, 'OmniWeb');
test.ok(!a.isFirefox, 'Firefox');
test.ok(!a.isWebkit, 'Webkit');
test.ok(!a.isChrome, 'Chrome');
test.ok(!a.isKonqueror, 'Konqueror');
test.ok(a.isDesktop, 'Desktop');
test.ok(!a.isWindows, 'Windows');
test.ok(!a.isLinux, 'Linux');
test.ok(a.isMac, 'Mac');
test.equal(a.Version, '622.8.0.112941');
test.done();
};
exports['OS X Safari 530'] = function(test) {
var s = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us)'

@@ -350,3 +438,3 @@ + ' AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19';

test.ok(!a.isKonqueror, 'Konqueror');
test.ok(a.isDesktop, 'Desktop'); // XXX it actually is desktop?
test.ok(a.isDesktop, 'Desktop');
test.ok(!a.isWindows, 'Windows');

@@ -370,11 +458,11 @@ test.ok(!a.isLinux, 'Linux');

test.ok(a.isMobile, 'Mobile'); // XXX not mobile?
test.ok(a.isMobile, 'Mobile');
test.ok(!a.isiPad, 'iPad');
test.ok(!a.isiPod, 'iPod');
test.ok(!a.isiPhone, 'iPhone');
test.ok(a.isAndroid, 'Android'); // XXX actually is android
test.ok(a.isAndroid, 'Android');
test.ok(!a.isBlackberry, 'Blackberry');
test.ok(!a.isOpera, 'Opera');
test.ok(!a.isIE, 'IE');
test.ok(a.isSafari, 'Safari'); // XXX Safari?
test.ok(a.isSafari, 'Safari');
test.ok(!a.isFirefox, 'Firefox');

@@ -384,3 +472,3 @@ test.ok(!a.isWebkit, 'Webkit');

test.ok(!a.isKonqueror, 'Konqueror');
test.ok(!a.isDesktop, 'Desktop'); // XXX desktop?
test.ok(!a.isDesktop, 'Desktop');
test.ok(!a.isWindows, 'Windows');

@@ -404,11 +492,11 @@ test.ok(a.isLinux, 'Linux');

test.ok(a.isMobile, 'Mobile'); // XXX not mobile?
test.ok(a.isMobile, 'Mobile');
test.ok(!a.isiPad, 'iPad');
test.ok(!a.isiPod, 'iPod');
test.ok(!a.isiPhone, 'iPhone');
test.ok(a.isAndroid, 'Android'); // XXX actually is android
test.ok(a.isAndroid, 'Android');
test.ok(!a.isBlackberry, 'Blackberry');
test.ok(!a.isOpera, 'Opera');
test.ok(!a.isIE, 'IE');
test.ok(a.isSafari, 'Safari'); // XXX Safari?
test.ok(a.isSafari, 'Safari');
test.ok(!a.isFirefox, 'Firefox');

@@ -418,3 +506,3 @@ test.ok(!a.isWebkit, 'Webkit');

test.ok(!a.isKonqueror, 'Konqueror');
test.ok(!a.isDesktop, 'Desktop'); // XXX desktop?
test.ok(!a.isDesktop, 'Desktop');
test.ok(!a.isWindows, 'Windows');

@@ -438,3 +526,3 @@ test.ok(a.isLinux, 'Linux');

test.ok(a.isMobile, 'Mobile'); // XXX actually mobile device?
test.ok(a.isMobile, 'Mobile');
test.ok(!a.isiPad, 'iPad');

@@ -455,3 +543,3 @@ test.ok(!a.isiPod, 'iPod');

test.ok(!a.isLinux, 'Linux');
test.ok(!a.isMac, 'Mac');
test.ok(a.isMac, 'Mac');
test.equal(a.Version, '5.0.2');

@@ -472,5 +560,3 @@

// XXX doesn't match anything
test.ok(a.isMobile, 'Mobile'); // XXX not a mobile device?
test.ok(a.isMobile, 'Mobile');
test.ok(!a.isiPad, 'iPad');

@@ -505,3 +591,2 @@ test.ok(!a.isiPod, 'iPod');

test.ok(!a.isMobile, 'Mobile');

@@ -508,0 +593,0 @@ test.ok(!a.isiPad, 'iPad');

@@ -7,3 +7,3 @@ /**

* @package express-useragent
* @version 0.0.4
* @version 0.0.8
* @copyright Copyright (c) 2009-2012 - All rights reserved.

@@ -10,0 +10,0 @@ * @license MIT License

@@ -7,3 +7,3 @@ /**

* @package express-useragent
* @version 0.0.4
* @version 0.0.8
* @copyright Copyright (c) 2009-2012 - All rights reserved.

@@ -10,0 +10,0 @@ * @license MIT License

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc