mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Fix undefined brandName when reading a field list that has no version
This commit is contained in:
parent
3622b614a7
commit
09904a0a47
@ -1056,7 +1056,7 @@
|
||||
var brands = uaCH[FULLVERLIST] || uaCH[BRANDS];
|
||||
if (brands) {
|
||||
for (var i in brands) {
|
||||
var brandName = brands[i].brand,
|
||||
var brandName = brands[i].brand || brands[i],
|
||||
brandVersion = brands[i].version;
|
||||
if (!/not.a.brand/i.test(brandName) && (i < 1 || /chromi/i.test(this.get(NAME)))) {
|
||||
this.set(NAME, strip(GOOGLE+' ', brandName))
|
||||
|
@ -490,4 +490,26 @@ describe('Map UA-CH headers', function () {
|
||||
assert.strictEqual(ua.device.type, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
it('Avoid error on headers variation', function () {
|
||||
|
||||
const headers2 = {
|
||||
'sec-ch-ua' : '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
|
||||
'sec-ch-ua-full-version-list' : '"Google Chrome", "Chromium", "Not?A_Brand";v="24.0.0.0"',
|
||||
'sec-ch-ua-full-version' : '""',
|
||||
'sec-ch-ua-mobile' : '?0',
|
||||
'sec-ch-ua-arch' : '""',
|
||||
'sec-ch-ua-bitness' : '""',
|
||||
'sec-ch-ua-model' : '""',
|
||||
'sec-ch-ua-platform' : '"Windows"',
|
||||
'sec-ch-ua-platform-version' : '""',
|
||||
'sec-ch-ua-wow64' : '?0',
|
||||
};
|
||||
|
||||
uap = UAParser(headers2).withClientHints();
|
||||
|
||||
assert.strictEqual(uap.browser.name, "Chrome");
|
||||
assert.strictEqual(uap.browser.version, undefined);
|
||||
assert.strictEqual(uap.browser.major, undefined);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user