semver4j
semver4j copied to clipboard
Issue with hyphen sign when used in build and pre release section
According to specification versions with hyphen sign in build section should be valid versions. In our project when we try to parse such versions we recieve exception. Example version: 1.2.3+123-abc
Also when there are more than one hyphen sign in pre release section version is not parsed correctly. For example if we have following version: 1.2.3-alpha-abc+123 when parsed it gets cut to 1.2.3-alpha-abc+123
I confirm, the issue happens also in the subversion. ie: 1.2+ should be a valid requirement, according to:
http://ant.apache.org/ivy/history/2.1.0/settings/version-matchers.html
We have the same issue with the NPM Requirement that pre-releases
with a -
within are not parsed correctly (NPE).
see tests
I am seeing an issue here as well when parsing NPM Requirements. I'm using version 3.1.0
Example ^2.26.3-1
(this is something out there in the wild -- a library called wiremock-standalone
)
When this is parsed, the first item on the list is a HYPHEN type token, so it goes down the 'upper and lower' path.
On lines 336 and 337 of Requirement.java, you are trying to get two more parts, expecting that it's the left and right side of the range, but since there's a caret, you are getting the caret in token2
.
In the Semver class constructor, calling 'trim()' on the value is causing an NPE.
When you use a non number i.e. ^2.26.3-beta
, on the right hand side it correctly detects the type as NPM.
So the root cause for my issue is because it is interpreting the Requirement as the wrong type of range i.e. not a caret range, but a hyphen range.
@KristianShishoev if you are still interesting, I've made copy of this lib and fix bug reported by you. Look for version 2.0.1