Skip to content

Commit

Permalink
DevTools: Include Edge in browser name detection (facebook#22584)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan authored and zhengjitf committed Apr 15, 2022
1 parent f5dd679 commit 4895916
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions packages/react-devtools-extensions/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@

import type {BrowserTheme} from 'react-devtools-shared/src/devtools/views/DevTools';

const IS_CHROME = navigator.userAgent.indexOf('Firefox') < 0;
const IS_EDGE = navigator.userAgent.indexOf('Edg') >= 0;
const IS_FIREFOX = navigator.userAgent.indexOf('Firefox') >= 0;
const IS_CHROME = IS_EDGE === false && IS_FIREFOX === false;

export type BrowserName = 'Chrome' | 'Firefox';
export type BrowserName = 'Chrome' | 'Firefox' | 'Edge';

export function getBrowserName(): BrowserName {
return IS_CHROME ? 'Chrome' : 'Firefox';
if (IS_EDGE) {
return 'Edge';
}
if (IS_FIREFOX) {
return 'Firefox';
}
if (IS_CHROME) {
return 'Chrome';
}
throw new Error(
'Expected browser name to be one of Chrome, Edge or Firefox.',
);
}

export function getBrowserTheme(): BrowserTheme {
Expand Down

0 comments on commit 4895916

Please sign in to comment.