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

.toString() returns Android 0.0.0 for Android 9 devices #130

Open
vmjames opened this issue Aug 30, 2018 · 4 comments
Open

.toString() returns Android 0.0.0 for Android 9 devices #130

vmjames opened this issue Aug 30, 2018 · 4 comments

Comments

@vmjames
Copy link

vmjames commented Aug 30, 2018

Parsing the header 'Mozilla/5.0 (Linux; Android 9; Pixel XL Build/PPR1.180610.009) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.91 Mobile Safari/537.36' and then calling .toString() to get the human readable form results in 'Chrome Mobile 68.0.3440 / Android 0.0.0' and not Android 9 as expected.

@3rd-Eden
Copy link
Owner

It probably means that there isn't a suitable parser yet for this user-agent string. Once it will be added to the https://github.com/ua-parser/uap-core project, it would parse, and stringify correctly.

@trustyoo86
Copy link

@3rd-Eden
When I tested useragent, it seems that Galaxy s10(Android 9) does not parse if useragent appears as follows.

Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G975N Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/9.2 Chrome/67.0.3396.87 Mobile Safari/537.3

I have checked that if the useragent string does not display as Android {major version}.{minor version}, it will be parsed and verified that no version is output. Is there an interface that can be customized to deal with It?

@queengooborg
Copy link

queengooborg commented Nov 28, 2020

Just a head's up that this is also affecting Android 11 on Google Pixel 2: Mozilla/5.0 (Linux; Android 11; Pixel 2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.101 Mobile Safari/537.36

My guess is that it's due to an expectation of the Android version number having a major and minor number, not just a major. By adding a ".0" to the end of the Android version, I get desirable results.

> const {parse} = require('useragent');
undefined
> parse('Mozilla/5.0 (Linux; Android 11; Pixel 2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.101 Mobile Safari/537.36').os
OperatingSystem {
  family: 'Android',
  major: '0',
  minor: '0',
  patch: '0'
}
> parse('Mozilla/5.0 (Linux; Android 11.0; Pixel 2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.101 Mobile Safari/537.36').os
OperatingSystem {
  family: 'Android',
  major: '11',
  minor: '0',
  patch: '0'
}

@VincentLeV
Copy link

VincentLeV commented Apr 22, 2024

I tested on Android 11, 12 and 14 and I also had this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants