Skip to content

Commit

Permalink
Change Chrome Android smartphone detection to allow "Mobile" anywhere. (
Browse files Browse the repository at this point in the history
  • Loading branch information
JBYoshi authored Feb 6, 2024
1 parent 59fb555 commit 1ed6514
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
4 changes: 2 additions & 2 deletions DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,9 @@ protected function parseDevice(): void
if (null === $this->device && 'Android' === $osFamily
&& $this->matchUserAgent('Chrome/[\.0-9]*')
) {
if ($this->matchUserAgent('(?:Mobile|eliboM) Safari/')) {
if ($this->matchUserAgent('(?:Mobile|eliboM)')) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE;
} elseif ($this->matchUserAgent('(?!Mobile )Safari/')) {
} else {
$this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/fixtures/clienthints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
engine: Blink
engine_version: "98.0.4758.101"
device:
type: tablet
type: smartphone
brand: ""
model: ""
os_family: Android
Expand Down
36 changes: 36 additions & 0 deletions Tests/fixtures/smartphone-37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7523,3 +7523,39 @@
model: Redmi 13C
os_family: Android
browser_family: Opera
-
user_agent: 'Mozilla/5.0 (Linux; U; Android 4.0.4; fa-ir) AppleWebKit/534.35 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.35 Puffin/2.10990AP Mobile'
os:
name: Android
version: "4.0.4"
platform: ""
client:
type: browser
name: Puffin
version: "2.10990"
engine: WebKit
engine_version: "534.35"
device:
type: smartphone
brand: ""
model: ""
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/113.0.5672.162 Mobile DuckDuckGo/5 Safari/537.36
os:
name: Android
version: "13"
platform: ""
client:
type: browser
name: DuckDuckGo Privacy Browser
version: "5"
engine: Blink
engine_version: "113.0.5672.162"
device:
type: smartphone
brand: ""
model: ""
os_family: Android
browser_family: Chrome
18 changes: 0 additions & 18 deletions Tests/fixtures/tablet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,6 @@
model: ""
os_family: Android
browser_family: Android Browser
-
user_agent: 'Mozilla/5.0 (Linux; U; Android 4.0.4; fa-ir) AppleWebKit/534.35 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.35 Puffin/2.10990AP Mobile'
os:
name: Android
version: "4.0.4"
platform: ""
client:
type: browser
name: Puffin
version: "2.10990"
engine: WebKit
engine_version: "534.35"
device:
type: tablet
brand: ""
model: ""
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; Android 4.4.2; Florida Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36
os:
Expand Down

0 comments on commit 1ed6514

Please sign in to comment.