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
brave/brave-browser#10165 (comment)
(cherry picked from commit 03b0a5a)
  • Loading branch information
faisalman committed Mar 4, 2023
1 parent f8e5a1f commit 73c2577
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ua-parser.js
Expand Up @@ -786,16 +786,21 @@
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;

this.getBrowser = function () {
var _browser = {};
_browser[NAME] = undefined;
_browser[VERSION] = undefined;
rgxMapper.call(_browser, _ua, _rgxmap.browser);
_browser.major = majorize(_browser.version);
_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 73c2577

Please sign in to comment.