diff --git a/packages/react-devtools-extensions/src/utils.js b/packages/react-devtools-extensions/src/utils.js index 2c67e2cf047b4..ea2bd27ee992a 100644 --- a/packages/react-devtools-extensions/src/utils.js +++ b/packages/react-devtools-extensions/src/utils.js @@ -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 {