Skip to content

Commit 218fa43

Browse files
committed
refactor: use strings.HasPrefix instead of regexp in ensurePrefix
1 parent e114959 commit 218fa43

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internal/version/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package version
1616

1717
import (
1818
"os"
19-
"regexp"
2019
"strings"
2120
)
2221

@@ -42,8 +41,9 @@ func getVersionFromEnv() string {
4241
}
4342

4443
// ensurePrefix ensures that the version string has a "v" prefix.
44+
// Empty strings are returned as-is to avoid producing a bare "v".
4545
func ensurePrefix(v string) string {
46-
if match, _ := regexp.MatchString(`^[^v]`, v); match {
46+
if v != "" && !strings.HasPrefix(v, "v") {
4747
return "v" + v
4848
}
4949
return v

0 commit comments

Comments
 (0)