Update semver regex

This commit is contained in:
gabriel0316 2024-04-10 10:44:35 +02:00 committed by GitHub
parent 1f3d2838d9
commit 4511275020
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -328,7 +328,7 @@ public class VersionUtilities {
if (Utilities.noString(version)) {
return false;
}
return version.matches("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-\\+]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-\\+][0-9a-zA-Z-\\+]*))*))?$");
return version.matches("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
}
/**

View File

@ -12,6 +12,7 @@ public class VersionUtilitiesTest {
assertTrue(VersionUtilities.isSemVer("0.1.1"));
assertTrue(VersionUtilities.isSemVer("0.1.1-ballot1"));
assertTrue(VersionUtilities.isSemVer("0.0.0-alpha.0.131"));
assertTrue(VersionUtilities.isSemVer("1.0.0+20130313144700"));
assertFalse(VersionUtilities.isSemVer("0.1.a"));
}