detect-browser
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -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|$)/ ], |
{ | ||
"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, |
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
9577
184
46