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

satisfies() using 1.*-style wildcard evaluates to false for all non 0 patch versions #70

Open
pichlermarc opened this issue Sep 29, 2023 · 1 comment · May be fixed by #71
Open

satisfies() using 1.*-style wildcard evaluates to false for all non 0 patch versions #70

pichlermarc opened this issue Sep 29, 2023 · 1 comment · May be fixed by #71

Comments

@pichlermarc
Copy link

Hi, thanks for your work on this package! 🙂

While troubleshooting, I came across some unexpected results. It looks like using a non-zero patch version will always evaluate to false if there's a wildcard for the minor version but not the patch version.

Some examples here to illustrate:

> const { satisfies } = require('compare-versions');
undefined
> satisfies('1.0.0', '1.*');
true
> satisfies('1.0.1', '1.*');
false
> satisfies('1.1.0', '1.*');
true
> satisfies('1.1.1', '1.*');
false

Additional info:

@Ankcorn
Copy link

Ankcorn commented Oct 1, 2023

Hey @pichlermarc,

I have taken a small look at the library and it looks like it is evaluating these conditions as false which the semvar library is evaluating to true

satisfies('3.0.3', '3.*')
satisfies('3.0.3', '3')

I believe this is because no operator is supplied so they are being compared with the = operator when "~" or "^" would provide the behaviour we need.

I have made a small PR #71 that changes this behaviour.

@Ankcorn Ankcorn linked a pull request Oct 1, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants