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

Incorrect satisfies result for NPM type #29

Open
hsz opened this issue Feb 12, 2018 · 2 comments
Open

Incorrect satisfies result for NPM type #29

hsz opened this issue Feb 12, 2018 · 2 comments

Comments

@hsz
Copy link

hsz commented Feb 12, 2018

When I'm trying to check if 2.6.9 satisfies following NPM range:

<= 2.6.8 || >= 3.0.0 <= 3.0.1

I get true result.

As a workaround I have to split it by || and test both parts separately - then I get two falses:

val semver = Semver("2.6.9", Semver.SemverType.NPM)

val invalid = semver.satisfies("<= 2.6.8 || >= 3.0.0 <= 3.0.1") // true - INVALID ❌
val result = "<= 2.6.8 || >= 3.0.0 <= 3.0.1".split("||").any { semver.satisfies(it) } // false ✔️
@ghost
Copy link

ghost commented Aug 22, 2019

Your observation is correct. The input

<= 2.6.8 || >= 3.0.0 <= 3.0.1

is a range consisting of two comparator sets <= 2.6.8 and >= 3.0.0 <= 3.0.1 which both are false.
Especially the second comparator set is false for 2.6.9.

Edit:

The list of tokens generated from this expression looks OK:

Token [type=OPENING, value=(]
Token [type=LTE, value=null]
Token [type=VERSION, value=2.6.8]
Token [type=CLOSING, value=)]
Token [type=OR, value=null]
Token [type=OPENING, value=(]
Token [type=GTE, value=null]
Token [type=VERSION, value=3.0.0]
Token [type=AND, value=null]
Token [type=LTE, value=null]
Token [type=VERSION, value=3.0.1]
Token [type=CLOSING, value=)]]

I am not sure if the list of tokens in RPN is OK, too:

Token [type=OR, value=null]
Token [type=AND, value=null]
Token [type=LTE, value=null]
Token [type=VERSION, value=2.6.8]
Token [type=GTE, value=null]
Token [type=VERSION, value=3.0.0]
Token [type=LTE, value=null]
Token [type=VERSION, value=3.0.1]

Is this correct?

@piotrooo
Copy link

@hsz if you are still interesting, I've made copy of this lib and fix bug reported by you. Look for version 2.0.1

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