Skip to content

Commit

Permalink
Fix for brave
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Aug 28, 2024
1 parent 83c5f47 commit 8d0b473
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 8d0b473

Please sign in to comment.