browser-info
Advanced tools
Comparing version 0.1.0 to 0.2.0
14
index.js
@@ -11,3 +11,3 @@ /* globals navigator*/ | ||
var match = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; | ||
var match = ua.match(/(opera|chrome|safari|firefox|msie|edge|trident(?=\/))\/?\s*(\d+)/i) || []; | ||
@@ -29,2 +29,5 @@ if (ua.indexOf('Win') !== -1) { | ||
} | ||
if (/iPad|iPhone|iPod/.test(ua)) { | ||
os = 'iOS'; | ||
} | ||
@@ -48,2 +51,11 @@ if (/trident/i.test(match[1])) { | ||
} | ||
tem = ua.match(/\bEdge\/(\d+)/); | ||
if (tem !== null) { | ||
return { | ||
name: 'Edge', | ||
version: tem[1], | ||
os: os | ||
}; | ||
} | ||
} | ||
@@ -50,0 +62,0 @@ match = match[2]? [match[1], match[2]]: [navigator.appName, navigator.appVersion, '-?']; |
{ | ||
"name": "browser-info", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Get browser info", | ||
@@ -5,0 +5,0 @@ "author": "Steve Lacy <me@slacy.me> (http://slacy.me)", |
@@ -27,2 +27,19 @@ 'use strict'; | ||
it('should detect iOS', function(done) { | ||
GLOBAL.navigator = { | ||
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1' | ||
}; | ||
should(info().os).equal('iOS'); | ||
done(); | ||
}); | ||
it('should detect Edge', function(done) { | ||
GLOBAL.navigator = { | ||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13' | ||
}; | ||
should(info().name).equal('Edge'); | ||
done(); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5358
97