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

detect-browser

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-browser - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

lib/detectBrowser.js

42

browser.js

@@ -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

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