1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Merge branch 'release/1.5.0' into production

This commit is contained in:
Denis Demchenko 2016-10-31 11:12:44 +02:00
commit 68b32f2347
6 changed files with 28 additions and 5 deletions

View File

@ -1,5 +1,9 @@
# Bowser Changelog # Bowser Changelog
### 1.5.0 (October 31, 2016)
- [ADD] Throw an error when `minVersion` map has not a string as a version and fix readme (#165)
- [FIX] Fix truly detection of Windows Phones (#167)
### 1.4.6 (September 19, 2016) ### 1.4.6 (September 19, 2016)
- [FIX] Fix mobile Opera's version detection on Android - [FIX] Fix mobile Opera's version detection on Android
- [FIX] Fix typescript typings — add `mobile` and `tablet` flags - [FIX] Fix typescript typings — add `mobile` and `tablet` flags

View File

@ -41,12 +41,12 @@ bowser.check({msie: "9.0"}); // false
/** /**
* specific user agent * specific user agent
*/ */
bowser.check({chrome: 45}, window.navigator.userAgent); // true bowser.check({chrome: "45"}, window.navigator.userAgent); // true
/** /**
* but false in strict mode * but false in strict mode
*/ */
bowser.check({chrome: 45}, true, window.navigator.userAgent); // false bowser.check({chrome: "45"}, true, window.navigator.userAgent); // false
``` ```
### bowser.compareVersions(versions`:Array<String>`)`:Number` ### bowser.compareVersions(versions`:Array<String>`)`:Number`

View File

@ -7,7 +7,7 @@
"sniff", "sniff",
"detection" "detection"
], ],
"version": "1.4.6", "version": "1.5.0",
"homepage": "https://github.com/ded/bowser", "homepage": "https://github.com/ded/bowser",
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)", "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
"main": "./src/bowser.js", "main": "./src/bowser.js",

View File

@ -321,9 +321,9 @@
} }
// set OS flags for platforms that have multiple browsers // set OS flags for platforms that have multiple browsers
if (!result.msedge && (android || result.silk)) { if (!result.windowsphone && !result.msedge && (android || result.silk)) {
result.android = t result.android = t
} else if (iosdevice) { } else if (!result.windowsphone && !result.msedge && iosdevice) {
result[iosdevice] = t result[iosdevice] = t
result.ios = t result.ios = t
} else if (mac) { } else if (mac) {
@ -540,6 +540,10 @@
for (var browser in minVersions) { for (var browser in minVersions) {
if (minVersions.hasOwnProperty(browser)) { if (minVersions.hasOwnProperty(browser)) {
if (_bowser[browser]) { if (_bowser[browser]) {
if (typeof minVersions[browser] !== 'string') {
throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));
}
// browser version and min supported version. // browser version and min supported version.
return compareVersions([version, minVersions[browser]]) < 0; return compareVersions([version, minVersions[browser]]) < 0;
} }

View File

@ -936,6 +936,15 @@ module.exports.useragents = {
, mobile: true , mobile: true
, a: true , a: true
} }
, 'Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Lumia 640 LTE) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537': {
windowsphone: true
, webkit: true
, osversion: '8.1'
, msie: true
, version: '11.0'
, mobile: true
, a: true
}
} }
, WebOS: { , WebOS: {
'Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.5; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0': { 'Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.5; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0': {

View File

@ -127,6 +127,12 @@ describe('Unsupported browser check', function() {
assert.equal(supported, false); assert.equal(supported, false);
}); });
it('should throw an error when minVersion map has a number, but not a string', function() {
assert.throws(() => {
browser.check({msie: 11}, this.ie10_6);
}, /Browser version in the minVersion map should be a string/);
});
it('should be passed by #check for IE10.6 when version was not specified', function() { it('should be passed by #check for IE10.6 when version was not specified', function() {
var supported = browser.check({}, this.ie10_6); var supported = browser.check({}, this.ie10_6);
assert.equal(supported, true); assert.equal(supported, true);