diff --git a/CHANGELOG.md b/CHANGELOG.md index d96d959..36ced52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index c35ac70..6492df3 100644 --- a/README.md +++ b/README.md @@ -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`)`:Number` diff --git a/package.json b/package.json index dead1b9..e80b312 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "sniff", "detection" ], - "version": "1.4.6", + "version": "1.5.0", "homepage": "https://github.com/ded/bowser", "author": "Dustin Diaz (http://dustindiaz.com)", "main": "./src/bowser.js", diff --git a/src/bowser.js b/src/bowser.js index d69268f..5afbc6a 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -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; } diff --git a/src/useragents.js b/src/useragents.js index e30aea3..4d2640d 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -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': { diff --git a/test/test.js b/test/test.js index 78d739b..eba2b2d 100644 --- a/test/test.js +++ b/test/test.js @@ -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);