Skip to content

Commit

Permalink
Fix #498 - Detect Brave Browser by checking navigator.brave
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Feb 24, 2023
1 parent d03c74d commit 03b0a5a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/ua-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,20 @@
return new UAParser(ua, extensions).getResult();
}

var _ua = ua || ((typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
var _uach = (typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgentData) ? window.navigator.userAgentData : undefined;
var _navigator = (typeof window !== UNDEF_TYPE && window.navigator) ? window.navigator : undefined;
var _ua = ua || ((_navigator && _navigator.userAgent) ? _navigator.userAgent : EMPTY);
var _uach = (_navigator && _navigator.userAgentData) ? _navigator.userAgentData : undefined;
var _rgxmap = extensions ? extend(regexes, extensions) : regexes;

// public methods
this.getBrowser = function () {
var _browser = new UABrowser();
rgxMapper.call(_browser, _ua, _rgxmap.browser);
_browser[MAJOR] = majorize(_browser[VERSION]);
// Brave-specific detection
if (_navigator && _navigator.brave && typeof _navigator.brave.isBrave == FUNC_TYPE) {
_browser[NAME] = 'Brave';
}
return _browser;
};
this.getCPU = function () {
Expand Down

0 comments on commit 03b0a5a

Please sign in to comment.