Skip to content

Commit

Permalink
Merge pull request #295 from ash-jc-allen/fix/uc-browser-bug
Browse files Browse the repository at this point in the history
Fix bug where the OS name cannot be determined from the user agent
  • Loading branch information
ash-jc-allen authored Aug 27, 2024
2 parents 6bcc485 + bb8c1a3 commit 195662f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Classes/UserAgent/ParserPhpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function getOperatingSystem(): ?string
return null;
}

return $this->parser->os->name ?: null;
/** @phpstan-ignore-next-line */
return $this->parser->os->name ?? null;
}

public function getOperatingSystemVersion(): ?string
Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Classes/ResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ public static function trackingFieldsProvider(): array
'device_type' => 'robot',
],
],

// UC Browser 7
[
'Mozilla/4.0 (compatible; MSIE 6.0; ) Opera/UCWEB7.0.2.37/28/999',
[
'operating_system' => null,
'operating_system_version' => null,
'browser' => 'UC Browser',
'browser_version' => '7.0',
'referer_url' => null,
'device_type' => 'mobile',
],
],
];
}

Expand Down

0 comments on commit 195662f

Please sign in to comment.