'satisfies' method sometimes failed #44

Closed
klimashkin opened this Issue Feb 26, 2014 · 1 comment

2 participants

@klimashkin

Hello!
If I have Opera 12.00, useragent returns me

{major: '12', minor: '00', patch: '0'}

And then semver 'satisfies' returns error

TypeError: Invalid Version: 12.00.0

because

Agent.prototype.satisfies = function satisfies (range) {
  return semver.satisfies(this.major + '.' + this.minor + '.' + this.patch, range);
};

Maybe it must be like this

Agent.prototype.satisfies = function satisfies (range) {
  return semver.satisfies((Number(this.major) || 0) + '.' + (Number(this.minor) || 0) + '.' + (Number(this.patch) || 0), range);
};
@3rd-Eden
Owner

Yes, that's because the satisfies assumes that the versioning scheme follows the semver specification. Parsing the values down to number would probably be a good idea. Could you create a pull request for that?

@klimashkin klimashkin added a commit to klimashkin/useragent that referenced this issue Jun 26, 2014
@klimashkin klimashkin Satisfies with semver fixes #44 383fdf5
@3rd-Eden 3rd-Eden closed this in #50 Jun 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment