Incorrect satisfies result for NPM type
Opened this issue · 2 comments
hsz commented
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 false
s:
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 ✔️
Deleted user commented
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 commented
@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