detect-browser
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -1,41 +0,3 @@ | ||
var browsers = [ | ||
[ 'edge', /Edge\/([0-9\._]+)/ ], | ||
[ 'chrome', /Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ ], | ||
[ 'firefox', /Firefox\/([0-9\.]+)(?:\s|$)/ ], | ||
[ 'opera', /Opera\/([0-9\.]+)(?:\s|$)/ ], | ||
[ 'ie', /Trident\/7\.0.*rv\:([0-9\.]+)\).*Gecko$/ ], | ||
[ 'ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/ ], | ||
[ 'ie', /MSIE\s(7\.0)/ ], | ||
[ 'bb10', /BB10;\sTouch.*Version\/([0-9\.]+)/ ], | ||
[ 'android', /Android\s([0-9\.]+)/ ], | ||
[ 'ios', /iPad\;\sCPU\sOS\s([0-9\._]+)/ ], | ||
[ 'ios', /iPhone\;\sCPU\siPhone\sOS\s([0-9\._]+)/ ], | ||
[ 'safari', /Safari\/([0-9\._]+)/ ] | ||
]; | ||
const detectBrowser = require('./lib/detectBrowser'); | ||
var i = 0, mapped =[]; | ||
for (i = 0; i < browsers.length; i++) { | ||
browsers[i] = createMatch(browsers[i]); | ||
if (isMatch(browsers[i])) { | ||
mapped.push(browsers[i]); | ||
} | ||
} | ||
var match = mapped[0]; | ||
var parts = match && match[3].split(/[._]/).slice(0,3); | ||
while (parts && parts.length < 3) { | ||
parts.push('0'); | ||
} | ||
// set the name and version | ||
exports.name = match && match[0]; | ||
exports.version = parts && parts.join('.'); | ||
function createMatch(pair) { | ||
return pair.concat(pair[1].exec(navigator.userAgent)); | ||
} | ||
function isMatch(pair) { | ||
return !!pair[2]; | ||
} | ||
module.exports = detectBrowser(navigator.userAgent); |
{ | ||
"name": "detect-browser", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Unpack a browser type and version from the useragent string", | ||
@@ -44,2 +44,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
@@ -1,23 +0,2 @@ | ||
var test = require('tape'); | ||
var semver = require('semver'); | ||
var browser; | ||
test('can run detection', function(t) { | ||
t.plan(1); | ||
t.ok(browser = require('../')); | ||
}); | ||
test('name detected', function(t) { | ||
t.plan(1); | ||
t.ok(browser.name, browser.name); | ||
}); | ||
test('version detected', function(t) { | ||
t.plan(1); | ||
t.ok(browser.version, browser.version); | ||
}); | ||
test('version is semver compatible', function(t) { | ||
t.plan(1); | ||
t.ok(semver.valid(browser.version)); | ||
}); | ||
require('./highLevel.js'); | ||
require('./logic.js'); |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
9419
12
179
2