Socket
Socket
Sign inDemoInstall

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.2.4 to 1.0.0

Makefile

12

index.js

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

*/
var UserAgent = require('./lib/express-useragent').UserAgent;
var usrg = require('./lib/express-useragent');
var UserAgent = usrg.UserAgent;
module.exports = new UserAgent();

@@ -20,4 +21,7 @@ module.exports.UserAgent = UserAgent;

return function (req, res, next) {
var source = req.headers['user-agent'] || '',
ua = new UserAgent();
var source = req.headers['user-agent'] || '';
if (req.headers['x-ucbrowser-ua']) { //special case of UC Browser
source = req.headers['x-ucbrowser-ua'];
}
var ua = new UserAgent();
if (typeof source === 'undefined') {

@@ -47,2 +51,2 @@ source = "unknown";

};
};
};

@@ -25,3 +25,4 @@ /*!

'pingdom',
'tumblr '
'tumblr ',
'Embedly'
];

@@ -47,3 +48,4 @@ var IS_BOT_REGEXP = new RegExp('^.*(' + BOTS.join('|') + ').*$');

Epiphany: /epiphany\/([\d\w\.\-]+)/i,
WinJs: /msapphost\/([\d\w\.\-]+)/i
WinJs: /msapphost\/([\d\w\.\-]+)/i,
UC: /UCBrowser\/([\d\w\.]+)/i
};

@@ -66,3 +68,4 @@ this._Browsers = {

Firefox: /firefox/i,
WinJs: /msapphost/i
WinJs: /msapphost/i,
UC: /UCBrowser/i
};

@@ -121,2 +124,3 @@ this._OS = {

this.DefaultAgent = {
isAuthoritative: true,
isMobile: false,

@@ -160,2 +164,3 @@ isTablet: false,

isSmartTV: false,
isUC : false,
silkAccelerated: false,

@@ -220,3 +225,11 @@ browser: 'unknown',

return 'Firefox';
case this._Browsers.UC.test(string):
this.Agent.isUC = true;
return 'UCBrowser';
default:
// If the UA does not start with Mozilla guess the user agent.
if (string.indexOf('Mozilla') !== 0 && /^([\d\w\-\.]+)\/[\d\w\.\-]+/i.test(string)) {
this.Agent.isAuthoritative = false;
return RegExp.$1;
}
return 'unknown';

@@ -304,7 +317,14 @@ }

break;
default:
regex = /#{name}[\/ ]([\d\w\.\-]+)/i;
if (regex.test(string)) {
case 'UCBrowser':
if (this._Versions.UC.test(string)) {
return RegExp.$1;
}
break;
default:
if (this.Agent.browser !== 'unknown') {
regex = new RegExp(this.Agent.browser + '[\\/ ]([\\d\\w\\.\\-]+)', 'i');
if (regex.test(string)) {
return RegExp.$1;
}
}
}

@@ -374,3 +394,3 @@ };

this.Agent.isMac = true;
return 'OS X Leopard';
return 'OS X Leopard';
case this._OS.OSXSnowLeopard.test(string):

@@ -612,2 +632,5 @@ this.Agent.isMac = true;

ua.Agent.isBot = isBot[1];
} else if (!ua.Agent.isAuthoritative) {
// Test unauthoritative parse for `bot` in UA to flag for bot
ua.Agent.isBot = /bot/i.test(ua.Agent.source);
}

@@ -614,0 +637,0 @@ };

{
"name": "express-useragent",
"description": "ExpressJS/Connect/TrinteJS user-agent middleware exposing",
"version": "0.2.4",
"version": "1.0.0",
"homepage": "https://github.com/biggora/express-useragent/",

@@ -65,3 +65,4 @@ "repository": {

"http": "node test/http.js",
"build-js": "grunt build"
"build": "grunt build",
"lint": "make lint"
},

@@ -77,2 +78,4 @@ "directories": {

"devDependencies": {
"nodeunit": "*",
"jshint": "*",
"bower": "*",

@@ -83,5 +86,4 @@ "express": ">= 3.0.0",

"grunt-contrib-uglify": "*",
"load-grunt-tasks": "^3.2.0",
"nodeunit": "*"
"load-grunt-tasks": "^3.2.0"
}
}

@@ -7,2 +7,42 @@ /**

exports['Arbitrary bot UA'] = function (test) {
var source = 'sockbot/3.1.0-RC1 (Linux x86_64) (nodejs 5.10.1) (owner:fred user:george)';
var userAgent = ua.parse(source);
test.ok(!userAgent.isAuthoritative, 'Authoritative');
test.ok(!userAgent.isMobile, 'Mobile');
test.ok(!userAgent.isiPad, 'iPad');
test.ok(!userAgent.isiPod, 'iPod');
test.ok(!userAgent.isiPhone, 'iPhone');
test.ok(!userAgent.isAndroid, 'Android');
test.ok(!userAgent.isBlackberry, 'Blackberry');
test.ok(!userAgent.isOpera, 'Opera');
test.ok(!userAgent.isIE, 'IE');
test.ok(!userAgent.isSafari, 'Safari');
test.ok(!userAgent.isFirefox, 'Firefox');
test.ok(!userAgent.isWebkit, 'Webkit');
test.ok(!userAgent.isChrome, 'Chrome');
test.ok(!userAgent.isKonqueror, 'Konqueror');
test.ok(!userAgent.isOmniWeb, 'OmniWeb');
test.ok(!userAgent.isSeaMonkey, 'SeaMonkey');
test.ok(!userAgent.isFlock, 'Flock');
test.ok(!userAgent.isAmaya, 'Amaya');
test.ok(!userAgent.isEpiphany, 'Epiphany');
test.ok(userAgent.isDesktop, 'Desktop');
test.ok(!userAgent.isWindows, 'Windows');
test.ok(userAgent.isLinux, 'Linux');
test.ok(!userAgent.isMac, 'Mac');
test.ok(!userAgent.isBada, 'Bada');
test.ok(!userAgent.isSamsung, 'Samsung');
test.ok(!userAgent.isRaspberry, 'Raspberry');
test.ok(userAgent.isBot, 'Bot');
test.ok(!userAgent.isAndroidTablet, 'AndroidTablet');
test.equal(userAgent.browser, 'sockbot');
test.equal(userAgent.version, '3.1.0-RC1');
test.done();
};
exports['Baiduspider Bot'] = function (test) {

@@ -14,2 +54,3 @@

test.ok(userAgent.isAuthoritative, 'Authoritative');
test.ok(!userAgent.isMobile, 'Mobile');

@@ -52,2 +93,3 @@ test.ok(!userAgent.isiPad, 'iPad');

test.ok(userAgent.isAuthoritative, 'Authoritative');
test.ok(!userAgent.isMobile, 'Mobile');

@@ -90,2 +132,3 @@ test.ok(!userAgent.isiPad, 'iPad');

test.ok(userAgent.isAuthoritative, 'Authoritative');
test.ok(!userAgent.isMobile, 'Mobile');

@@ -92,0 +135,0 @@ test.ok(!userAgent.isiPad, 'iPad');

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

test.ok(a.isAuthoritative, 'Authoritative');
test.ok(a.isMobile, 'Mobile');

@@ -45,2 +46,3 @@ test.ok(a.isiPad, 'iPad');

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

@@ -75,2 +77,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -105,2 +108,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -137,2 +141,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -168,2 +173,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -200,2 +206,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -231,2 +238,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -262,2 +270,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -294,2 +303,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -325,2 +335,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -355,2 +366,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -385,2 +397,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -415,2 +428,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -446,2 +460,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -477,2 +492,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -508,2 +524,3 @@ test.ok(!a.isiPad, 'iPad');

test.ok(a.isAuthoritative, 'Authoritative');
test.ok(a.isMobile, 'Mobile');

@@ -539,2 +556,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -571,2 +589,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -601,2 +620,3 @@ test.ok(!a.isiPad, 'iPad');

test.ok(a.isAuthoritative, 'Authoritative');
test.ok(a.isMobile, 'Mobile');

@@ -636,2 +656,3 @@ test.ok(a.isiPad, 'iPad');

test.ok(a.isAuthoritative, 'Authoritative');
test.ok(a.isMobile, 'Mobile');

@@ -670,2 +691,3 @@ test.ok(!a.isiPad, 'iPad');

test.ok(a.isAuthoritative, 'Authoritative');
test.ok(a.isMobile, 'Mobile');

@@ -738,2 +760,3 @@ test.ok(!a.isiPad, 'iPad');

test.ok(a.isAuthoritative, 'Authoritative');
test.ok(a.isMobile, 'Mobile');

@@ -770,2 +793,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -829,2 +853,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -858,2 +883,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -888,2 +914,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -918,2 +945,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -949,2 +977,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -980,2 +1009,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -1011,2 +1041,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -1043,2 +1074,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -1075,2 +1107,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -1107,2 +1140,3 @@ test.ok(!a.isiPad, 'iPad');

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

@@ -1140,2 +1174,3 @@ test.ok(!a.isiPad, 'iPad');

test.ok(a.isAuthoritative, 'Authoritative');
test.ok(a.isMobile, 'Mobile');

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

@@ -15,4 +15,4 @@ /**

var http = require('http')
, useragent = require('./../');
var http = require('http');
var useragent = require('../');

@@ -19,0 +19,0 @@ var app = http.createServer(function (req, res) {

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