express-useragent
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -55,2 +55,3 @@ /** | ||
Windows2000: /windows nt 5\.0/i, | ||
WindowsPhone8: /windows phone 8\./, | ||
OSX: /os x (\d+)[._](\d+)/i, | ||
@@ -64,6 +65,8 @@ Mac: /os x/i, | ||
iPhone: /\(iPhone.*os (\d+)[._](\d+)/i, | ||
Bada: /Bada\/(\d+)\.(\d+)/i | ||
Bada: /Bada\/(\d+)\.(\d+)/i, | ||
Curl: /curl\/(\d+)\.(\d+)\.(\d+)/i | ||
}; | ||
this._Platform = { | ||
Windows: /windows/i, | ||
Windows: /windows nt/i, | ||
WindowsPhone: /windows phone/i, | ||
Mac: /macintosh/i, | ||
@@ -78,3 +81,4 @@ Linux: /linux/i, | ||
Blackberry: /blackberry/i, | ||
Samsung: /samsung/i | ||
Samsung: /samsung/i, | ||
Curl: /curl/i | ||
}; | ||
@@ -110,2 +114,3 @@ this.Agent = {}; | ||
isBot : false, | ||
isCurl : false, | ||
isAndroidTablet : false, | ||
@@ -263,2 +268,4 @@ Browser : 'unknown', | ||
return 'Windows 2000'; | ||
case this._OS.WindowsPhone8.test(string): | ||
return 'Windows Phone 8'; | ||
case this._OS.Linux.test(string): | ||
@@ -288,2 +295,5 @@ this.Agent.isLinux = true; | ||
return 'Bada'; | ||
case this._OS.Curl.test(string): | ||
this.Agent.isCurl = true; | ||
return 'Curl'; | ||
default: | ||
@@ -297,4 +307,9 @@ return 'unknown'; | ||
return "Microsoft Windows"; | ||
case this._Platform.WindowsPhone.test(string): | ||
this.Agent.isWindowsPhone = true; | ||
return "Microsoft Windows Phone"; | ||
case this._Platform.Mac.test(string): | ||
return "Apple Mac"; | ||
case this._Platform.Curl.test(string): | ||
return "Curl"; | ||
case this._Platform.Android.test(string): | ||
@@ -383,2 +398,3 @@ this.Agent.isAndroid = true; | ||
case ua.Agent.isAndroid: | ||
case ua.Agent.isWindowsPhone: | ||
ua.Agent.isMobile = true; | ||
@@ -406,3 +422,3 @@ ua.Agent.isDesktop = false; | ||
var ua = this; | ||
if(/googlebot|gurujibot|yandexbot|slurp|msnbot|bingbot/i.test(ua.Agent.source)) { | ||
if(/googlebot|gurujibot|yandexbot|slurp|msnbot|bingbot|facebookexternalhit/i.test(ua.Agent.source)) { | ||
ua.Agent.isBot = true; | ||
@@ -409,0 +425,0 @@ } |
{ | ||
"name": "express-useragent", | ||
"description": "ExpressJS/Connect user-agent middleware exposing", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"homepage": "https://github.com/biggora/express-useragent/", | ||
@@ -6,0 +6,0 @@ "repository": { |
[![build status](https://secure.travis-ci.org/biggora/express-useragent.png)](http://travis-ci.org/biggora/express-useragent) | ||
[![NPM version](https://badge.fury.io/js/express-useragent.png)](http://badge.fury.io/js/express-useragent) | ||
# Middleware exposing user-agent for [NodeJS](http://nodejs.org/) | ||
# Fast Middleware exposing user-agent for [NodeJS](http://nodejs.org/) | ||
@@ -5,0 +5,0 @@ express-useragent is a simple ExpressJS user-agent middleware exposing user-agent details to your application and views. |
@@ -31,2 +31,3 @@ /** | ||
test.ok(a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '5.1'); | ||
@@ -61,2 +62,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '3.5.16'); | ||
@@ -90,2 +92,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '11.0'); | ||
@@ -120,2 +123,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '17.0.963.56'); | ||
@@ -151,2 +155,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '2.30.6'); | ||
@@ -180,2 +185,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '28.0.1500.95'); | ||
@@ -210,2 +216,3 @@ test.equal(a.OS, 'Windows 8'); | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '23.0'); | ||
@@ -240,2 +247,3 @@ test.equal(a.OS, 'Windows 7'); | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '5.5'); | ||
@@ -269,2 +277,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '6.0'); | ||
@@ -298,2 +307,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '7.0'); | ||
@@ -327,2 +337,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '11.62'); | ||
@@ -357,2 +368,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '5.1.1'); | ||
@@ -387,2 +399,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '18.0.1025.162'); | ||
@@ -393,3 +406,32 @@ | ||
exports['Windows Phone 8'] = function(test) { | ||
var s = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; ' + | ||
'Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)'; | ||
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.isWindowsPhone, 'Windows Phone'); | ||
test.ok(!a.isLinux, 'Linux'); | ||
test.ok(!a.isMac, 'Mac'); | ||
test.equal(a.Version, '10.0'); | ||
test.done(); | ||
}; | ||
exports['OS X OmniWeb 622'] = function(test) { | ||
@@ -420,2 +462,3 @@ | ||
test.ok(a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '622.8.0.112941'); | ||
@@ -450,2 +493,3 @@ | ||
test.ok(a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '4.0.2'); | ||
@@ -483,2 +527,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '4.0'); | ||
@@ -516,2 +561,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '4.0'); | ||
@@ -549,2 +595,3 @@ | ||
test.ok(a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '5.0.2'); | ||
@@ -582,2 +629,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, undefined); | ||
@@ -613,2 +661,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '7.0'); | ||
@@ -642,2 +691,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '10.6'); | ||
@@ -671,2 +721,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '11.0'); | ||
@@ -700,2 +751,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '8.0'); | ||
@@ -730,2 +782,3 @@ | ||
test.equal(a.Version, '8.0'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.ok(a.isIECompatibilityMode); | ||
@@ -759,2 +812,3 @@ | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '10.0'); | ||
@@ -789,2 +843,3 @@ test.ok(!a.isIECompatibilityMode); | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '10.0'); | ||
@@ -819,2 +874,3 @@ test.ok(a.isIECompatibilityMode); | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '7.0'); | ||
@@ -849,2 +905,3 @@ test.ok(!a.isIECompatibilityMode); | ||
test.ok(!a.isMac, 'Mac'); | ||
test.ok(!a.isWindowsPhone, 'Windows Phone'); | ||
test.equal(a.Version, '9.0'); | ||
@@ -854,2 +911,2 @@ test.ok(a.isIECompatibilityMode); | ||
test.done(); | ||
}; | ||
}; |
57429
13
1388