Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public Provider() {

String remaining = versionStr;

if (Character.toLowerCase(remaining.charAt(0)) == 'v') {
remaining = remaining.substring(1);
if (remaining.isEmpty()) {
throw new InvalidVersionException(versionStr, "Version must not be empty");
}
}

final int metaIndex = remaining.indexOf('+');
if (metaIndex >= 0) {
this.metadata = remaining.substring(metaIndex + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ void testParseLeadingZeros() {
assertThat(version.toString()).isEqualTo("1.0.1");
}

@Test
void testParseWithVPrefix() {
// https://github.com/nscuro/versatile/issues/301
final var version = new NugetVersion("v8.0.0");
assertThat(version.toString()).isEqualTo("8.0.0");
assertThat(version.isStable()).isTrue();
}

@Test
void testCompareWithVPrefix() {
// https://github.com/nscuro/versatile/issues/301
assertThat(new NugetVersion("v4.0.0")).isLessThan(new NugetVersion("8.0.0"));
assertThat(new NugetVersion("v8.0.0")).isEqualTo(new NugetVersion("8.0.0"));
}

@Test
void testParseRealWorldPreview() {
final var version = new NugetVersion("9.0.0-preview.1.24080.9");
Expand Down