Open vmjames opened 5 years ago
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.
@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?
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'
}
I tested on Android 11, 12 and 14 and I also had this issue
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.