-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Unfortunately, the problem originally reported in #35 still persists for exact same example UA string:
UAInspector.parse("Mozilla/5.0 (Linux; arm_64; Android 10; Mi Note 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5765.05 Mobile Safari/537.36"
I have done some digging - my findings follow below:
Although there is a regression test added at
ua_inspector/test/ua_inspector/parser/client_test.exs
Lines 39 to 54 in 8954721
| test "engine version with leading zero in fourth place (x.y.z.0[0-9]+)" do | |
| agent = | |
| "Mozilla/5.0 (Linux; arm_64; Android 10; Mi Note 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.5765.05 Mobile Safari/537.36" | |
| parsed = UAInspector.parse(agent) | |
| result = %UAInspector.Result.Client{ | |
| engine: "WebKit", | |
| engine_version: "537.36", | |
| name: "Chrome Mobile", | |
| type: "browser", | |
| version: "115.0.5765.05" | |
| } | |
| assert ^result = parsed.client | |
| end |
| if :lt != Util.Version.compare(version, engine_version) do |
The root problem here seems to be the fact that after semver conversion for comparison, the version string ends up like this:
UAInspector.Util.Version.to_semver("115.0.5765.05", 4)
"115.0.5765-05"
which in turn causes
| Version.compare(semver1, semver2) |
Version follows that spec). Unfortunately, apparently versions in UA do not always follow the conventions.
Perhaps it would make sense to sanitize the prerelease by trimming any leading zeroes somewhere close to
ua_inspector/lib/ua_inspector/util/version.ex
Lines 157 to 161 in 8954721
| if String.contains?(semver, "-") do | |
| semver | |
| else | |
| semver <> "-0" | |
| end |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels