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.4.0 to 1.5.0

test/index.js

1

lib/detectBrowser.js

@@ -5,2 +5,3 @@ module.exports = function detectBrowser(userAgentString) {

[ 'chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ ],
[ 'crios', /CriOS\/([0-9\.]+)(:?\s|$)/ ],
[ 'firefox', /Firefox\/([0-9\.]+)(?:\s|$)/ ],

@@ -7,0 +8,0 @@ [ 'opera', /Opera\/([0-9\.]+)(?:\s|$)/ ],

18

package.json
{
"name": "detect-browser",
"version": "1.4.0",
"version": "1.5.0",
"description": "Unpack a browser type and version from the useragent string",

@@ -8,3 +8,4 @@ "main": "index.js",

"scripts": {
"test": "node test/all.js",
"test": "node test",
"prepublish": "npm run test",
"gendocs": "gendocs > README.md"

@@ -31,16 +32,3 @@ },

"tape": "^4.2.2"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/6..latest",
"chrome/22..latest",
"firefox/16..latest",
"safari/latest",
"opera/11.0..latest",
"iphone/6",
"ipad/6",
"android-browser/latest"
]
}
}

@@ -10,5 +10,2 @@ # detect-browser

[![browser support](https://ci.testling.com/DamonOehlman/detect-browser.png)](https://ci.testling.com/DamonOehlman/detect-browser)
[![stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/dominictarr/stability#stable) [![Build Status](https://api.travis-ci.org/DamonOehlman/detect-browser.svg?branch=master)](https://travis-ci.org/DamonOehlman/detect-browser) [![bitHound Score](https://www.bithound.io/github/DamonOehlman/detect-browser/badges/score.svg)](https://www.bithound.io/github/DamonOehlman/detect-browser)

@@ -15,0 +12,0 @@

@@ -0,23 +1,23 @@

var semver = require('semver');
var browser = require('../');
var test = require('tape');
var semver = require('semver');
var browser;
test('can run detection', function(t) {
t.plan(1);
t.ok(browser = require('../'));
t.ok(browser, require.cache[require.resolve('../')]);
t.end();
});
test('name detected', function(t) {
t.plan(1);
t.ok(browser.name, browser.name);
t.end();
});
test('version detected', function(t) {
t.plan(1);
t.ok(browser.version, browser.version);
t.end();
});
test('version is semver compatible', function(t) {
t.plan(1);
t.ok(semver.valid(browser.version));
t.end();
});
var test = require('tape');
var detectBrowser = require('../lib/detectBrowser');
function assertAgentString(t, agentString, extectedResult) {
t.deepEqual(detectBrowser(agentString), extectedResult);
function assertAgentString(t, agentString, expectedResult) {
t.deepEqual(detectBrowser(agentString), expectedResult);
}

@@ -22,2 +22,11 @@

test('detects Chrome for iOS', function(t) {
assertAgentString(t,
'Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3',
{ name: 'crios', version: '19.0.1084' }
);
t.end();
});
test('detects Firefox', function(t) {

@@ -24,0 +33,0 @@ assertAgentString(t,

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