Skip to content

Commit

Permalink
Additional fix for blank user agent string.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesiscoding committed Dec 29, 2020
1 parent be56eb1 commit 1308832
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"retina"
],
"homepage": "https://github.com/jonesiscoding/device",
"version": "4.0.7",
"version": "4.0.8",
"suggest": {
"deviscoding/poly-pointer": "Psuedo-Polyfill for (pointer:coarse). Easy support of touch devices."
},
Expand Down
9 changes: 7 additions & 2 deletions src/Device/Hints.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,19 @@ protected function isUserAgentMatch($needle, &$regexMatches = null)

foreach ($needles as $needle)
{
if (!is_null($regexMatches))
if (null === $ua)
{
// Only if user agent is empty AND no needles are given.
return false;
}
elseif (!is_null($regexMatches))
{
if (!preg_match($needle, $ua, $regexMatches))
{
return false;
}
}
elseif (false === stripos($this->getUserAgent(), $needle))
elseif (false === stripos($ua, $needle))
{
return false;
}
Expand Down

0 comments on commit 1308832

Please sign in to comment.