compare-versions
compare-versions copied to clipboard
`satisfies()` using `1.*`-style wildcard evaluates to `false` for all non `0` patch versions
Hi, thanks for your work on this package! :slightly_smiling_face:
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:
-
[email protected]
- Node.js:
v18.12.1
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 https://github.com/omichelsen/compare-versions/pull/71 that changes this behaviour.