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] unexpected semver.maxSatisfying(versions, semver.validRange(version)) behaviour #382

Closed
paulo-ferraz-oliveira opened this issue May 13, 2021 · 2 comments

Comments

@paulo-ferraz-oliveira
Copy link

What / Why

  • semver.validRange('24') returns '>=24.0.0 <25.0.0-0', which is seemingly Okay (24 is user input),
  • semver.maxSatisfying(['24.0'], '>=24.0.0 <25.0.0-0') returns null, which seems to indicate the lib. is contradicting itself (24.0 is from a list of available versions).

Where

  • v7.3.5

How

Current Behavior

  • check "What / Why?"

Expected Behavior

  • semver.maxSatisfying(['24.0'], '>=24.0.0 <25.0.0-0') should return 24.0.

References

@paulo-ferraz-oliveira paulo-ferraz-oliveira changed the title [BUG] <title> [BUG] unexpected semver.maxSatisfying(versions, semver.validRange(version)) behaviour May 13, 2021
@lukekarrys
Copy link
Contributor

lukekarrys commented Apr 10, 2022

The first parameter of maxSatisfying is an array of versions, but 24.0 is a range not a version.

> semver.maxSatisfying(['24.0'], '>=24.0.0 <25.0.0-0')
null
> semver.maxSatisfying(['24.0.0'], '>=24.0.0 <25.0.0-0')
'24.0.0'

I would recommend calling semver.coerce on the input first to convert it from a range-like into a version:

> semver.maxSatisfying([semver.coerce('24.0').version], '>=24.0.0 <25.0.0-0')
'24.0.0'

@paulo-ferraz-oliveira
Copy link
Author

Yeah, this is what we ended up doing, a few months back. Thanks.

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

2 participants