Skip to content

Commit

Permalink
fix: check for undefined userAgent string before calling includes() (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pgautier404 authored Dec 2, 2024
1 parent 388e478 commit a12be86
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ export class ClientMetadataProvider {
// Each browser uses its own JS engine, the best we can do is detect the browser name.
// Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator
function getBrowserName(userAgent: string): string {
// Check for empty string, null, or undefined.
if (!userAgent) {
return 'unknown-browser';
}
// The order matters here, and this may report false positives for unlisted browsers.

if (userAgent.includes('Firefox')) {
// "Mozilla/5.0 (X11; Linux i686; rv:104.0) Gecko/20100101 Firefox/104.0"
return 'Mozilla-Firefox';
Expand Down

0 comments on commit a12be86

Please sign in to comment.