Skip to content
New issue

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

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

Already on GitHub? # to your account

Add detect LeafOS #7862

Closed
sanchezzzhak opened this issue Oct 14, 2024 · 3 comments · Fixed by #7864 or #7863
Closed

Add detect LeafOS #7862

sanchezzzhak opened this issue Oct 14, 2024 · 3 comments · Fixed by #7864 or #7863

Comments

@sanchezzzhak
Copy link
Collaborator

current parse result:

user_agent: Mozilla/5.0 (Linux; Android 14; LeafOS on ARM64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36
os:
  name: Android
  version: "14"
  platform: ARM
os_family: Android

expected result

user_agent: Mozilla/5.0 (Linux; Android 14; LeafOS on ARM64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36
os:
  name: LeafOS
  version: ""
  platform: ARM
os_family: Android

site https://leafos.org/

@sanchezzzhak
Copy link
Collaborator Author

original UA: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36
client hints:
  brands:
    - brand: Not/A)Brand
      version: '8'
    - brand: Chromium
      version: '126'
  fullVersionList:
    - brand: Not/A)Brand
      version: 8.0.0.0
    - brand: Chromium
      version: 126.0.6478.71
  mobile: '1'
  model: LeafOS on ARM64
  platform: Android
  platformVersion: 14.0.0
  uaFullVersion: 126.0.6478.71
  wow64: '0'

liviuconcioiu added a commit to liviuconcioiu/device-detector that referenced this issue Oct 14, 2024
@liviuconcioiu
Copy link
Collaborator

sanchezzzhak pushed a commit that referenced this issue Oct 14, 2024
@sanchezzzhak
Copy link
Collaborator Author

create common method from AbstractParser and move code

public function restoreUserAgentFromClientHints(): void 
{
        $deviceModel  =  $this->clientHints?->getModel() ??  '';
        
        if ('' === $deviceModel) {
             return;
        }

        // is freeze user-agent then restoring the original UA for the device definition
        if ($this->hasUserAgentClientHintsFragment()) {
            $osVersion = $this->clientHints->getOperatingSystemVersion();
            $this->setUserAgent((string) \preg_replace(
                '(Android (?:10[.\d]*; K|1[1-5]))',
                \sprintf('Android %s; %s', '' !== $osVersion ? $osVersion : '10', $deviceModel),
                $this->userAgent
            ));
        }

        // is freeze user-agent then restoring the original UA for the device definition
        if ($this->hasDesktopFragment()) {
            $this->setUserAgent((string) \preg_replace(
                '(X11; Linux x86_64)',
                \sprintf('X11; Linux x86_64; %s', $deviceModel),
                $this->userAgent
            ));
        }
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants