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
### 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)
- [FIX] Fix mobile Opera's version detection on Android
- [FIX] Fix typescript typings — add `mobile` and `tablet` flags

View File

@ -41,12 +41,12 @@ bowser.check({msie: "9.0"}); // false
/**
* specific user agent
*/
bowser.check({chrome: 45}, window.navigator.userAgent); // true
bowser.check({chrome: "45"}, window.navigator.userAgent); // true
/**
* 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`

View File

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

View File

@ -321,9 +321,9 @@
}
// 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
} else if (iosdevice) {
} else if (!result.windowsphone && !result.msedge && iosdevice) {
result[iosdevice] = t
result.ios = t
} else if (mac) {
@ -540,6 +540,10 @@
for (var browser in minVersions) {
if (minVersions.hasOwnProperty(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.
return compareVersions([version, minVersions[browser]]) < 0;
}

View File

@ -936,6 +936,15 @@ module.exports.useragents = {
, mobile: 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: {
'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);
});
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() {
var supported = browser.check({}, this.ie10_6);
assert.equal(supported, true);