Skip to content

Commit

Permalink
Detect Edge browser correctly (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
victrme committed Nov 8, 2024
1 parent a295a14 commit 71f6cef
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/scripts/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ export const PLATFORM =
? 'safari'
: 'online'

export const BROWSER =
window.navigator.userAgent.toLowerCase().indexOf('edge') > -1
? 'edge'
: window.navigator?.userAgentData?.brands.some((b) => b.brand === 'Opera')
? 'opera'
: window.navigator?.userAgentData?.brands.some((b) => b.brand === 'Chromium')
? 'chrome'
: window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1
? 'firefox'
: window.navigator.userAgent.toLowerCase().indexOf('safari') > -1
? 'safari'
: 'other'
export const BROWSER = window.navigator?.userAgentData?.brands.some((b) => b.brand === 'Microsoft Edge')
? 'edge'
: window.navigator?.userAgentData?.brands.some((b) => b.brand === 'Opera')
? 'opera'
: window.navigator?.userAgentData?.brands.some((b) => b.brand === 'Chromium')
? 'chrome'
: window.navigator.userAgent.toLowerCase().indexOf('firefox') > -1
? 'firefox'
: window.navigator.userAgent.toLowerCase().indexOf('safari') > -1
? 'safari'
: 'other'

export const EXTENSION: typeof chrome | typeof browser | undefined =
PLATFORM === 'online' ? undefined : PLATFORM === 'firefox' ? browser : chrome
Expand Down

0 comments on commit 71f6cef

Please sign in to comment.