From d2dbee0e6cdbb28000e055f2be3b5fae8e951628 Mon Sep 17 00:00:00 2001 From: xnerhu Date: Sun, 5 Nov 2023 13:56:47 +0100 Subject: [PATCH] add edge browserkind --- src/types.ts | 1 + src/utils/browser.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/types.ts b/src/types.ts index 28e767de..c1bdecbc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -170,4 +170,5 @@ export const enum BrowserKind { Safari = 'safari', IE = 'internet_explorer', WeChat = 'wechat', + Edge = 'edge', } diff --git a/src/utils/browser.ts b/src/utils/browser.ts index aefb336d..375358b5 100644 --- a/src/utils/browser.ts +++ b/src/utils/browser.ts @@ -52,7 +52,13 @@ 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 @@ -60,10 +66,6 @@ export function getBrowserKind(): BrowserKind { 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 }