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

Fix detection for Android 8 OPR6 build number

Android 8 Chrome 60 was being detected as Opera.
This commit is contained in:
Jason Pang 2017-08-25 21:23:35 -07:00
parent 0afa24ff30
commit f96d7e60dc
2 changed files with 38 additions and 17 deletions

View File

@ -56,7 +56,7 @@
, opera: t
, version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)
}
} else if (/opr|opios/i.test(ua)) {
} else if (/opr|opios/i.test(ua) && !/\/opr/i.test(ua)) {
// a new Opera
result = {
name: 'Opera'

View File

@ -142,5 +142,26 @@ describe('Unsupported browser check', function() {
var supported = browser.check({}, true, this.ie10_6);
assert.equal(supported, false);
});
});
})
describe('Android 8.0.0 OPR6 build type not confused for the Opera browser', function () {
before(function () {
this.android8_opr6_ua = "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPR6.170623.013) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.107 Mobile Safari/537.36";
this.opera_ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36 OPR/47.0.2631.55";
});
it('Android 8 Chrome 60 user agent should be detected as Chrome 60', function () {
var flags = browser._detect(this.android8_opr6_ua);
assert.equal(flags.chrome, true);
assert.equal(flags.version, "60.0");
assert.equal(flags.opera, undefined);
});
it('Opera user agent should be detected as Opera 47', function () {
var flags = browser._detect(this.opera_ua);
assert.equal(flags.opera, true);
assert.equal(flags.version, "47.0");
assert.equal(flags.chrome, undefined);
});
});