1
0
mirror of https://github.com/lancedikson/bowser synced 2026-02-09 17:40:09 +00:00

Add Brave browser support using clientHints mechanism

Co-authored-by: naorpeled <6171622+naorpeled@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-01 21:59:34 +00:00
parent 51d0e0e045
commit f5d89c124d
3 changed files with 55 additions and 0 deletions

View File

@ -7,6 +7,7 @@ export const BROWSER_ALIASES_MAP = {
BaiduSpider: 'baiduspider',
Bada: 'bada',
BingCrawler: 'bingcrawler',
Brave: 'brave',
BlackBerry: 'blackberry',
'ChatGPT-User': 'chatgpt_user',
Chrome: 'chrome',
@ -77,6 +78,7 @@ export const BROWSER_MAP = {
bada: 'Bada',
bingcrawler: 'BingCrawler',
blackberry: 'BlackBerry',
brave: 'Brave',
chatgpt_user: 'ChatGPT-User',
chrome: 'Chrome',
claudebot: 'ClaudeBot',

View File

@ -1020,6 +1020,29 @@ const browsersList = [
return browser;
},
},
/* Brave Browser */
{
test(parser) {
// Check Client Hints brands for Brave
return parser.hasBrand('Brave');
},
describe(ua, parser) {
const browser = {
name: 'Brave',
};
// Try Client Hints brand version first
if (parser) {
const hintsVersion = parser.getBrandVersion('Brave');
if (hintsVersion) {
browser.version = hintsVersion;
return browser;
}
}
return browser;
},
},
{
test: [/chromium/i],
describe(ua) {

View File

@ -383,3 +383,33 @@ test('Parser with Edge client hints', (t) => {
t.true(p.hasBrand('Chromium'));
t.is(p.getBrandVersion('Microsoft Edge'), '131');
});
const BRAVE_HINTS = {
brands: [
{ brand: 'Brave', version: '1.73.97' },
{ brand: 'Chromium', version: '131' },
{ brand: 'Not_A Brand', version: '24' },
],
mobile: false,
platform: 'Windows',
platformVersion: '15.0.0',
};
const BRAVE_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
test('Parser detects Brave from client hints brands', (t) => {
const p = new Parser(BRAVE_UA, false, BRAVE_HINTS);
t.is(p.getBrowserName(), 'Brave');
t.is(p.getBrowserVersion(), '1.73.97');
});
test('Parser.hasBrand detects Brave', (t) => {
const p = new Parser(BRAVE_UA, false, BRAVE_HINTS);
t.true(p.hasBrand('Brave'));
t.true(p.hasBrand('brave'));
});
test('Parser.getBrandVersion returns version for Brave', (t) => {
const p = new Parser(BRAVE_UA, false, BRAVE_HINTS);
t.is(p.getBrandVersion('Brave'), '1.73.97');
});