Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves detect desktop and detect devices for brand: Dell #6734

Merged
merged 5 commits into from May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions DeviceDetector.php
Expand Up @@ -741,6 +741,18 @@ protected function hasAndroidMobileFragment(): bool
return !!$this->matchUserAgent($regex);
}

/**
* Returns if the parsed UA contains the 'Android; Mobile;' fragment
sanchezzzhak marked this conversation as resolved.
Show resolved Hide resolved
*
* @return bool
*/
protected function hasDesktopFragment(): bool
{
$regex = 'Desktop x(32|64);';

return !!$this->matchUserAgent($regex);
}

/**
* Returns if the parsed UA contains usage of a mobile only browser
*
Expand Down Expand Up @@ -943,6 +955,17 @@ protected function parseDevice(): void
$this->device = AbstractDeviceParser::DEVICE_TYPE_TV;
}

/**
* Set device type desktop if string ua contains desktop
*/
$hasDesktop = AbstractDeviceParser::DEVICE_TYPE_DESKTOP !== $this->device
&& false !== \strpos($this->userAgent, 'Desktop')
&& $this->hasDesktopFragment();

if ($hasDesktop) {
$this->device = AbstractDeviceParser::DEVICE_TYPE_DESKTOP;
}

// set device type to desktop for all devices running a desktop os that were not detected as another device type
if (null !== $this->device || !$this->isDesktop()) {
return;
Expand Down
32 changes: 32 additions & 0 deletions Tests/fixtures/desktop.yml
Expand Up @@ -7264,3 +7264,35 @@
model: BilimBook Mini
os_family: Android
browser_family: Chrome
-
user_agent: Microsoft Office OneNote/16.0.13328.20478 (Windows/10.0; Desktop x64; en-GB; Universal app; Dell Inc./XPS 13 9360)
os:
name: Windows
version: "10.0"
platform: x64
client:
type: mobile app
name: Microsoft Office OneNote
version: 16.0.13328.20478
device:
type: desktop
brand: Dell
model: XPS 13 9360
os_family: Windows
browser_family: Unknown
-
user_agent: Microsoft Office OneNote/16.0.13328.20478 (Windows/10.0; Desktop x64; en-GB; Universal app; Dell Inc./XXX TEST)
os:
name: Windows
version: "10.0"
platform: x64
client:
type: mobile app
name: Microsoft Office OneNote
version: 16.0.13328.20478
device:
type: desktop
brand: Dell
model: ""
os_family: Windows
browser_family: Unknown
3 changes: 3 additions & 0 deletions regexes/device/mobiles.yml
Expand Up @@ -4550,6 +4550,9 @@ Dell:
- regex: '(?:Dell )?(Streak|Venue) ?([^/;]*) Build'
model: '$1 $2'
device: 'tablet'
- regex: 'Dell Inc./(XPS 13 9360)(?:[);/ ]|$)'
device: 'desktop'
model: '$1'
- regex: 'Dell; ((?:Streak|Venue)[^;/\)]*)'
model: '$1'
device: 'tablet'
Expand Down