WalkerCodeRanger/semver

Incorrect Order For "Negative" Prerelease Identifiers

Closed this issue · 1 comments

When a prerelease identifier could be parsed as a negative integer (e.g. -1) then it is treated as a negative numeric prerelease identifier for the purposes of precedence and sort order. This is incorrect. According to the spec, such an identifier is an alphanumeric identifier that should always come after the numeric identifiers and be sorted lexically.

For example, currently 1.0.0-pre.-1 < 1.0.0-pre.0 < 1.0.0-pre.alpha but the correct order is 1.0.0-pre.0 < 1.0.0-pre.alpha < 1.0.0-pre.-1.

In v2.2.0 the old comparison operators and methods have been marked [Obsolete]. The new comparison methods correctly handle "negative" prerelease identifiers.