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

Bug on "Old" Safari : Wrong version detection #153

Open
LeComptoirDesPharmacies opened this issue Oct 14, 2020 · 1 comment
Open

Bug on "Old" Safari : Wrong version detection #153

LeComptoirDesPharmacies opened this issue Oct 14, 2020 · 1 comment

Comments

@LeComptoirDesPharmacies
Copy link
Contributor

Hi,

It seems that there is a bug in UserAgent parsing when it is run on "old" Safari Browser.
Ex :
Mozilla/5.0 (iPhone; CPU iPhone OS 9_0_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A405 Safari/601.1
Result is :
BrowserInfo {name: "ios", version: "9...0", os: "iOS", type: "browser"}

However, "9...0" is not semver compliant.
This is due to the fact that Safari 9 do not manage String.split(regexp) very well. (See http://blog.stevenlevithan.com/archives/cross-browser-split)
For example :
console.log('9.0'.split(/[._]/))
Will give :
[0: "9", 1: ".", 2: "0"]

Suggestion, replace (See https://www.xspdf.com/resolution/52116414.html) :
let versionParts = match[1] && match[1].split(/[._]/).slice(0, 3);
With :
let versionParts = match[1] && match[1].split('.').join('_').split('_').slice(0, 3);

Yours faithfully,
LCDP

@LeComptoirDesPharmacies
Copy link
Contributor Author

PR proposal here : #154

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

0 participants