From 8d0b473850418be76ebdb6873a3a79e809f6862d Mon Sep 17 00:00:00 2001 From: Hexagon Date: Wed, 28 Aug 2024 21:56:59 +0000 Subject: [PATCH] Fix for brave --- mod.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod.ts b/mod.ts index b54635c..4eb51bf 100644 --- a/mod.ts +++ b/mod.ts @@ -238,6 +238,8 @@ export function getCurrentProduct(): Product { case Runtime.Fastly: return Product.Fastly; case Runtime.Browser: { + // Brave can not be detected from user agent string, handle separately + if (verifyGlobal("brave") && "brave" in navigator) return Product.Brave; // For browser, get the specific browser const userAgent = navigator.userAgent; return getProductFromUserAgent(userAgent); @@ -252,7 +254,6 @@ export function getCurrentProduct(): Product { */ export function getProductFromUserAgent(userAgent: string): Product { if (userAgent.indexOf("Opera") !== -1 || userAgent.indexOf("OPR") !== -1) return Product.Opera; - if ("brave" in navigator) return Product.Brave; if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1) return Product.Safari; if (userAgent.indexOf("Edg") !== -1) return Product.Edge; if (userAgent.indexOf("Chrome") !== -1) return Product.Chrome;