mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
Update engine.version
to be the same as browser.version
for Chromium-based browser when UA-CH is available
This commit is contained in:
parent
20e195de8b
commit
aa56b2f4f3
@ -85,6 +85,7 @@
|
||||
PREFIX_MOBILE = 'Mobile ',
|
||||
SUFFIX_BROWSER = ' Browser',
|
||||
CHROME = 'Chrome',
|
||||
CHROMIUM = 'Chromium',
|
||||
CHROMECAST = 'Chromecast',
|
||||
EDGE = 'Edge',
|
||||
FIREFOX = 'Firefox',
|
||||
@ -1161,17 +1162,21 @@
|
||||
|
||||
switch (this.itemType) {
|
||||
case UA_BROWSER:
|
||||
case UA_ENGINE:
|
||||
var brands = uaCH[FULLVERLIST] || uaCH[BRANDS], prevName;
|
||||
if (brands) {
|
||||
for (var i in brands) {
|
||||
var brandName = strip(/(Google|Microsoft) /, brands[i].brand || brands[i]),
|
||||
brandVersion = brands[i].version;
|
||||
if (!/not.a.brand/i.test(brandName) && (!prevName || (/chrom/i.test(prevName) && !/chromi/i.test(brandName)))) {
|
||||
if (this.itemType == UA_BROWSER && !/not.a.brand/i.test(brandName) && (!prevName || (/chrom/i.test(prevName) && brandName != CHROMIUM))) {
|
||||
this.set(NAME, brandName)
|
||||
.set(VERSION, brandVersion)
|
||||
.set(MAJOR, majorize(brandVersion));
|
||||
prevName = brandName;
|
||||
}
|
||||
if (this.itemType == UA_ENGINE && brandName == CHROMIUM) {
|
||||
this.set(VERSION, brandVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -9,7 +9,7 @@ var browsers = require('./specs/browser/browser-all.json');
|
||||
var cpus = require('./specs/cpu/cpu-all.json');
|
||||
var devices = readJsonFiles('test/specs/device');
|
||||
var engines = require('./specs/engine/engine-all.json');
|
||||
var os = require('./specs/os/os-all.json');
|
||||
var os = readJsonFiles('test/specs/os');
|
||||
var { Headers } = require('node-fetch');
|
||||
|
||||
function readJsonFiles(dir) {
|
||||
@ -395,9 +395,9 @@ describe('Map UA-CH headers', function () {
|
||||
assert.strictEqual(device.model, "Pixel 99");
|
||||
assert.strictEqual(device.vendor, undefined);
|
||||
assert.strictEqual(uap.engine.name, 'Blink');
|
||||
assert.strictEqual(uap.engine.version, '110.0.0.0');
|
||||
assert.strictEqual(uap.engine.version, '93.0.1.2');
|
||||
assert.strictEqual(engine.name, 'Blink');
|
||||
assert.strictEqual(engine.version, '110.0.0.0');
|
||||
assert.strictEqual(engine.version, '93.0.1.2');
|
||||
assert.strictEqual(uap.os.name, "Windows");
|
||||
assert.strictEqual(uap.os.version, "11");
|
||||
assert.strictEqual(os.name, "Windows");
|
||||
|
Loading…
x
Reference in New Issue
Block a user