Skip to content

Commit

Permalink
Update engine.version to be the same as browser.version for Chrom…
Browse files Browse the repository at this point in the history
…ium-based browser when UA-CH is available
  • Loading branch information
faisalman committed Nov 28, 2024
1 parent 20e195d commit aa56b2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/main/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
PREFIX_MOBILE = 'Mobile ',
SUFFIX_BROWSER = ' Browser',
CHROME = 'Chrome',
CHROMIUM = 'Chromium',
CHROMECAST = 'Chromecast',
EDGE = 'Edge',
FIREFOX = 'Firefox',
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions test/mocha-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit aa56b2f

Please sign in to comment.