diff --git a/pkg/utils/version/getCleanVersion.go b/pkg/utils/version/getCleanVersion.go index c52f07c..ad10535 100644 --- a/pkg/utils/version/getCleanVersion.go +++ b/pkg/utils/version/getCleanVersion.go @@ -10,7 +10,7 @@ func GetCleanVersion(version string) (string, string) { return "", "" } - re := regexp.MustCompile(`([^0-9]*)(\d?)\.?(\d?)\.?(\d?)(.*)`) + re := regexp.MustCompile(`([^0-9]*)(\d*)\.?(\d*)\.?(\d*)(.*)`) reSubmatch := re.FindStringSubmatch(version) // [0] all, [1] = prefix, [2] = major, [3] = minor, [4] = patch prefix := reSubmatch[1] diff --git a/pkg/utils/version/getCleanVersion_test.go b/pkg/utils/version/getCleanVersion_test.go index b8b8ce9..5821035 100644 --- a/pkg/utils/version/getCleanVersion_test.go +++ b/pkg/utils/version/getCleanVersion_test.go @@ -35,6 +35,11 @@ func TestGetCleanVersion(t *testing.T) { expectedPrefix: "^", expectedVersion: "1.2.3", }, + { + version: "^15.0.0-canary.102", + expectedPrefix: "^", + expectedVersion: "15.0.0", + }, { version: "^1", expectedPrefix: "^", @@ -45,6 +50,16 @@ func TestGetCleanVersion(t *testing.T) { expectedPrefix: "^", expectedVersion: "1.2.0", }, + { + version: "12.34.56", + expectedPrefix: "", + expectedVersion: "12.34.56", + }, + { + version: "123.3456", + expectedPrefix: "", + expectedVersion: "123.3456.0", + }, } for _, tc := range testCases {