Skip to content

Commit

Permalink
add edge browserkind
Browse files Browse the repository at this point in the history
  • Loading branch information
xnerhu committed Nov 5, 2023
1 parent d76a9fe commit d2dbee0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,5 @@ export const enum BrowserKind {
Safari = 'safari',
IE = 'internet_explorer',
WeChat = 'wechat',
Edge = 'edge',
}
12 changes: 7 additions & 5 deletions src/utils/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,20 @@ export function getBrowserEngineKind(): BrowserEngineKind {

export function getBrowserKind(): BrowserKind {
const userAgent = navigator.userAgent?.toLowerCase()
if (strIncludes(userAgent, 'wechat')) {
if (strIncludes(userAgent, 'edg/')) {
return BrowserKind.Edge
} else if (strIncludes(userAgent, 'safari')) {
return BrowserKind.Safari
} else if (strIncludes(userAgent, 'trident') || strIncludes(userAgent, 'msie')) {
return BrowserKind.IE
} else if (strIncludes(userAgent, 'wechat')) {
return BrowserKind.WeChat
} else if (strIncludes(userAgent, 'firefox')) {
return BrowserKind.Firefox
} else if (strIncludes(userAgent, 'opera') || strIncludes(userAgent, 'opr')) {
return BrowserKind.Opera
} else if (strIncludes(userAgent, 'chrome')) {
return BrowserKind.Chrome
} else if (strIncludes(userAgent, 'safari')) {
return BrowserKind.Safari
} else if (strIncludes(userAgent, 'trident') || strIncludes(userAgent, 'msie')) {
return BrowserKind.IE
} else {
return BrowserKind.Unknown
}
Expand Down

0 comments on commit d2dbee0

Please sign in to comment.