browserslist-useragent-ruby icon indicating copy to clipboard operation
browserslist-useragent-ruby copied to clipboard

ArgumentError on old versions of Chrome

Open qrush opened this issue 6 years ago • 3 comments

We're using this gem and on the following Chrome 53 UA string:

Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/535.14.61 (KHTML, like Gecko) Chrome/53.5.0289.5916 Safari/534.43

We received the following error:

ArgumentError
53.5.0289 is not a valid SemVer Version (http://semver.org)

It seems that this is definitely an allowable version number. Could I suggest using Gem::Version to parse the version number instead? I also think this gem should define its own exception class if there's a true problem with parsing as well instead of just throwing an ArgumentError, which is very broad and could potentially mask lots of other issues.

qrush avatar Aug 02 '19 07:08 qrush

Hey @qrush , thank for the issue! The sematic version is used here to match the current version with target version. As I know Gem::Version class do not allow to do it in that way.

I suppose, it would be better to fix the issue by changing the semver regexp here for allowing the browsers format

How do you think are you able to fix the issue by sending PR?

dsalahutdinov avatar Aug 02 '19 08:08 dsalahutdinov

Same error with UA Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

alaz avatar Jan 12 '20 11:01 alaz

SemVer doesn't allow leading zeros, so that change is probably not going to happen in the Semantic gem. And as some browsers don't use SemVer anyways, the current approach doesn't seem future proof. I had a quick look to change the logic to use Gem::Version or Gem::Dependency, but it seems tricky to cover all the current use cases.

Any other ideas?

calmyournerves avatar Mar 25 '20 12:03 calmyournerves