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] semver.lt returns wrong value for pre-release version comparison #483

Open
1 task done
Tracked by #501
IainSAP opened this issue Sep 22, 2022 · 1 comment
Open
1 task done
Tracked by #501
Labels
Bug thing that needs fixing

Comments

@IainSAP
Copy link

IainSAP commented Sep 22, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Using semver.lt() returns the incorrect value when comparing pre-release version with includePrerelease set to false (or the default).

image

By comparison, explicitly coercing you get:

semver_1.lt(semver_1.coerce('0.2.0-1'), minVersion)
false

My assumption is that strings are implicitly coerced when calling comparison functions, perhaps this is incorrect?

Expected Behavior

semver.lt('0.2.0-1', '0.2.0', { includePrerelease: false }) should return false.

Steps To Reproduce

  1. In node shell
  2. With the current latest version of semver installed
  3. Run 'require('semver').lt('0.2.0-1', '0.2.0', { includePrerelease: false })
  4. Wrong value true is returned

Environment

  • npm: 6.14.15
  • Node: 14.8.1
  • OS: Mac Monterey 12.5.1
  • platform: Macbook Pro i9
@IainSAP IainSAP added Bug thing that needs fixing Needs Triage needs an initial review labels Sep 22, 2022
@IainSAP IainSAP changed the title [BUG] <title> [BUG] semver.lt returns wrong value for pre-release version comparison Sep 22, 2022
@lukekarrys
Copy link
Member

This is similar to #345, and I think the fix might even be the same for both.

@lukekarrys lukekarrys removed the Needs Triage needs an initial review label Oct 27, 2022
@wraithgar wraithgar mentioned this issue Apr 17, 2023
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants