diff --git a/decompress.go b/decompress.go index babdcf7..866249c 100644 --- a/decompress.go +++ b/decompress.go @@ -144,7 +144,7 @@ func matchExecutableName(cmd, os, arch, target string) bool { cmd = strings.TrimSuffix(cmd, ".exe") pattern := regexp.MustCompile( fmt.Sprintf( - `^%s([_-]%s)?([_-]%s[_-]%s)?(\.exe)?$`, + `^%s([_-]v?%s)?([_-]%s[_-]%s)?(\.exe)?$`, regexp.QuoteMeta(cmd), semverPattern, regexp.QuoteMeta(os), diff --git a/decompress_test.go b/decompress_test.go index d310b4f..856e33c 100644 --- a/decompress_test.go +++ b/decompress_test.go @@ -124,28 +124,42 @@ func TestMatchExecutableName(t *testing.T) { {"gostuff", "linux", "amd64", "gostuff", true}, {"gostuff", "linux", "amd64", "gostuff_0.16.0", true}, {"gostuff", "linux", "amd64", "gostuff-0.16.0", true}, + {"gostuff", "linux", "amd64", "gostuff_v0.16.0", true}, + {"gostuff", "linux", "amd64", "gostuff-v0.16.0", true}, {"gostuff", "linux", "amd64", "gostuff_linux_amd64", true}, {"gostuff", "linux", "amd64", "gostuff-linux-amd64", true}, {"gostuff", "linux", "amd64", "gostuff_0.16.0_linux_amd64", true}, {"gostuff", "linux", "amd64", "gostuff-0.16.0-linux-amd64", true}, + {"gostuff", "linux", "amd64", "gostuff_v0.16.0_linux_amd64", true}, + {"gostuff", "linux", "amd64", "gostuff-v0.16.0-linux-amd64", true}, // invalid {"gostuff", "linux", "amd64", "gostuff_darwin_amd64", false}, {"gostuff", "linux", "amd64", "gostuff0.16.0", false}, + {"gostuff", "linux", "amd64", "gostuffv0.16.0", false}, {"gostuff", "linux", "amd64", "gostuff_0.16.0_amd64", false}, + {"gostuff", "linux", "amd64", "gostuff_v0.16.0_amd64", false}, {"gostuff", "linux", "amd64", "gostuff_0.16.0_linux", false}, + {"gostuff", "linux", "amd64", "gostuff_v0.16.0_linux", false}, // windows valid {"gostuff", "windows", "amd64", "gostuff.exe", true}, {"gostuff", "windows", "amd64", "gostuff_0.16.0.exe", true}, {"gostuff", "windows", "amd64", "gostuff-0.16.0.exe", true}, + {"gostuff", "windows", "amd64", "gostuff_v0.16.0.exe", true}, + {"gostuff", "windows", "amd64", "gostuff-v0.16.0.exe", true}, {"gostuff", "windows", "amd64", "gostuff_windows_amd64.exe", true}, {"gostuff", "windows", "amd64", "gostuff-windows-amd64.exe", true}, {"gostuff", "windows", "amd64", "gostuff_0.16.0_windows_amd64.exe", true}, {"gostuff", "windows", "amd64", "gostuff-0.16.0-windows-amd64.exe", true}, + {"gostuff", "windows", "amd64", "gostuff_v0.16.0_windows_amd64.exe", true}, + {"gostuff", "windows", "amd64", "gostuff-v0.16.0-windows-amd64.exe", true}, // windows invalid {"gostuff", "windows", "amd64", "gostuff_darwin_amd64.exe", false}, {"gostuff", "windows", "amd64", "gostuff0.16.0.exe", false}, {"gostuff", "windows", "amd64", "gostuff_0.16.0_amd64.exe", false}, {"gostuff", "windows", "amd64", "gostuff_0.16.0_windows.exe", false}, + {"gostuff", "windows", "amd64", "gostuffv0.16.0.exe", false}, + {"gostuff", "windows", "amd64", "gostuff_v0.16.0_amd64.exe", false}, + {"gostuff", "windows", "amd64", "gostuff_v0.16.0_windows.exe", false}, } for _, testItem := range testData {