Skip to content

Commit a087d9f

Browse files
author
Michael Lehenbauer
committed
Fix to not detect normal Chrome.
1 parent 0a575a3 commit a087d9f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/util/src/environment.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,19 @@ export function isBrowser(): boolean {
7575
/**
7676
* Detect browser extensions (Chrome and Firefox at least).
7777
*/
78-
declare const chrome: { runtime?: unknown };
79-
declare const browser: { runtime?: unknown };
78+
interface BrowserRuntime {
79+
id?: unknown;
80+
}
81+
declare const chrome: { runtime?: BrowserRuntime };
82+
declare const browser: { runtime?: BrowserRuntime };
8083
export function isBrowserExtension(): boolean {
81-
return (
82-
(typeof chrome === 'object' && chrome.runtime !== undefined) ||
83-
(typeof browser === 'object' && browser.runtime !== undefined)
84-
);
84+
const runtime =
85+
typeof chrome === 'object'
86+
? chrome.runtime
87+
: typeof browser === 'object'
88+
? browser.runtime
89+
: undefined;
90+
return typeof runtime === 'object' && runtime.id !== undefined;
8591
}
8692

8793
/**

0 commit comments

Comments
 (0)