From e44ca1de6ec1b8f7564b67493e6c14de900be3f7 Mon Sep 17 00:00:00 2001 From: Benoit de La Forest Date: Thu, 27 Oct 2016 17:47:18 +0200 Subject: [PATCH 1/6] fix windowsphone flagged as android Closes #167 --- src/bowser.js | 2 +- src/useragents.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bowser.js b/src/bowser.js index d69268f..fcffbcd 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -321,7 +321,7 @@ } // 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) { result[iosdevice] = t diff --git a/src/useragents.js b/src/useragents.js index e30aea3..b1855dd 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -936,6 +936,14 @@ 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 535)': { + windowsphone: 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': { From 9f31efa62fed0aaecd445f4efc4d73f0a8e239a0 Mon Sep 17 00:00:00 2001 From: Benoit de La Forest Date: Fri, 28 Oct 2016 13:01:55 +0200 Subject: [PATCH 2/6] Fix WindowsPhone flagged as iOS Related to !168 --- src/bowser.js | 2 +- src/useragents.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bowser.js b/src/bowser.js index fcffbcd..d13577c 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -323,7 +323,7 @@ // set OS flags for platforms that have multiple browsers 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) { diff --git a/src/useragents.js b/src/useragents.js index b1855dd..4d2640d 100644 --- a/src/useragents.js +++ b/src/useragents.js @@ -936,8 +936,9 @@ 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 535)': { + , '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' From 8b92707e7bac329de5d159b23025e70d5f0010aa Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 31 Oct 2016 11:07:15 +0200 Subject: [PATCH 3/6] Throw an error when minVersion map has not a string as a browser version fixes #165 --- src/bowser.js | 4 ++++ test/test.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/bowser.js b/src/bowser.js index d13577c..5afbc6a 100644 --- a/src/bowser.js +++ b/src/bowser.js @@ -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/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); From 61b368d3bff958c5669733734270f8a083608def Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 31 Oct 2016 11:12:12 +0200 Subject: [PATCH 4/6] Fix `bowser.check` specification (a string instead of a number) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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` From 9a833e186f93f9976afd29364b0e2917927e5f97 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 31 Oct 2016 11:12:27 +0200 Subject: [PATCH 5/6] Bump version to 1.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From a87dbaf348e35c840aaed9f95e9f87a32f96daf9 Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Mon, 31 Oct 2016 11:12:37 +0200 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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