mirror of
https://github.com/lancedikson/bowser
synced 2026-03-02 03:40:27 +00:00
feat: add Vivaldi client hints support
This commit is contained in:
@@ -761,11 +761,29 @@ const browsersList = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: [/vivaldi/i],
|
test(parser) {
|
||||||
describe(ua) {
|
// Check Client Hints brands for Vivaldi
|
||||||
|
if (parser.hasBrand('Vivaldi')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Fall back to UA string detection
|
||||||
|
return parser.test(/vivaldi/i);
|
||||||
|
},
|
||||||
|
describe(ua, parser) {
|
||||||
const browser = {
|
const browser = {
|
||||||
name: 'Vivaldi',
|
name: 'Vivaldi',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Try Client Hints brand version first
|
||||||
|
if (parser) {
|
||||||
|
const hintsVersion = parser.getBrandVersion('Vivaldi');
|
||||||
|
if (hintsVersion) {
|
||||||
|
browser.version = hintsVersion;
|
||||||
|
return browser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to UA string version
|
||||||
const version = Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
|
const version = Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
|
|||||||
@@ -2595,6 +2595,21 @@
|
|||||||
type: "desktop"
|
type: "desktop"
|
||||||
engine:
|
engine:
|
||||||
name: "Blink"
|
name: "Blink"
|
||||||
|
-
|
||||||
|
ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Vivaldi/7.8.3925.66"
|
||||||
|
spec:
|
||||||
|
browser:
|
||||||
|
name: "Vivaldi"
|
||||||
|
version: "7.8.3925.66"
|
||||||
|
os:
|
||||||
|
name: "macOS"
|
||||||
|
version: "10.15.7"
|
||||||
|
versionName: "Catalina"
|
||||||
|
platform:
|
||||||
|
type: "desktop"
|
||||||
|
vendor: "Apple"
|
||||||
|
engine:
|
||||||
|
name: "Blink"
|
||||||
Generic:
|
Generic:
|
||||||
-
|
-
|
||||||
ua: "Generic/2.15 libww"
|
ua: "Generic/2.15 libww"
|
||||||
|
|||||||
@@ -419,3 +419,33 @@ test('Parser.getBrandVersion returns version for Brave', (t) => {
|
|||||||
const p = new Parser(BRAVE_UA, false, BRAVE_HINTS);
|
const p = new Parser(BRAVE_UA, false, BRAVE_HINTS);
|
||||||
t.is(p.getBrandVersion('Brave'), '144');
|
t.is(p.getBrandVersion('Brave'), '144');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const VIVALDI_HINTS = {
|
||||||
|
brands: [
|
||||||
|
{ brand: 'Vivaldi', version: '7.1' },
|
||||||
|
{ brand: 'Chromium', version: '134' },
|
||||||
|
{ brand: 'Not_A Brand', version: '24' },
|
||||||
|
],
|
||||||
|
mobile: false,
|
||||||
|
platform: 'Windows',
|
||||||
|
platformVersion: '15.0.0',
|
||||||
|
};
|
||||||
|
|
||||||
|
const VIVALDI_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36';
|
||||||
|
|
||||||
|
test('Parser detects Vivaldi from client hints brands', (t) => {
|
||||||
|
const p = new Parser(VIVALDI_UA, false, VIVALDI_HINTS);
|
||||||
|
t.is(p.getBrowserName(), 'Vivaldi');
|
||||||
|
t.is(p.getBrowserVersion(), '7.1');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parser.hasBrand detects Vivaldi', (t) => {
|
||||||
|
const p = new Parser(VIVALDI_UA, false, VIVALDI_HINTS);
|
||||||
|
t.true(p.hasBrand('Vivaldi'));
|
||||||
|
t.true(p.hasBrand('vivaldi'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parser.getBrandVersion returns version for Vivaldi', (t) => {
|
||||||
|
const p = new Parser(VIVALDI_UA, false, VIVALDI_HINTS);
|
||||||
|
t.is(p.getBrandVersion('Vivaldi'), '7.1');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user