WalkerCodeRanger / semver

A semantic version library for .NET fully compliant with v2.0.0 of the spec found at http://semver.org/.
MIT License
293 stars 46 forks source link

SemVersionRange.Parse("1.x.x") throws an exception #86

Open Confuzed opened 3 hours ago

Confuzed commented 3 hours ago

Describe the bug

SemVersionRange.Parse("1.x.x") throws an exception, calling the 'x' an invalid character.

SemVersionRange.Parse("1.x.x", SemVersionRangeOptions.OptionalMinorPatch); also throws.

Unhandled exception. System.FormatException: Minor version contains invalid character 'x' in '1.x.x'.
   at Semver.SemVersionRange.Parse(String range, SemVersionRangeOptions options, Int32 maxLength)
   at Semver.SemVersionRange.Parse(String range, Int32 maxLength)
   at Program.Main()

According to the semver 2 spec, it is valid to use 'x' as a wildcard for semver ranges.

Steps To Reproduce

Code to repro/test the issue: https://dotnetfiddle.net/VI7QmU

Expected behavior

Input 1.x.x to get parsed in to a range equivalent to ~1.

Versions(please complete the following information):

Additional context

I encountered this issue when using the library to parse Helm chart repository indexes, which sometimes contain versions in the form '2.x.x' in the chart dependencies.

Confuzed commented 3 hours ago

Just tested this using version 3.0.0-beta.2 and the result is the same.