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 @@ -156,13 +156,15 @@ public static Version parse(String version) {
throw new NumberFormatException("Invalid version format '" + version + "', expected two dots!");
}

int indexThirdDot = version.indexOf('.', indexSecondDot + 1);
int indexFirstDash = version.indexOf('-');

int versionEnd;
if (indexFirstDash == -1) {
if (indexFirstDash == -1 && indexThirdDot == -1) {
versionEnd = version.length();
}
else {
} else if (indexThirdDot != -1) {
versionEnd = indexThirdDot;
} else {
versionEnd = indexFirstDash;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ void testParse() {
Version.parse("1.5.2"));
}

@Test
void testParseSuffixedVersion() {
Assertions.assertEquals(new Version(1, 5, 4, false),
Version.parse("1.5.4.foobar-007"));
Assertions.assertEquals(new Version(1, 5, 4, false),
Version.parse("1.5.4.foobar"));
}

@Test
void testParseSnapshot() {
Assertions.assertEquals(new Version(1, 5, 2, true),
Expand Down