Skip to content

Commit

Permalink
fix(v2): handle space in non-devel go version (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz authored Jun 13, 2023
1 parent 67efbd3 commit fd7bca0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions v2/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func goVersion() string {
s = s[:p]
}
return s
} else if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
s = s[:p]
}

notSemverRune := func(r rune) bool {
Expand Down
4 changes: 4 additions & 0 deletions v2/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func TestGoVersion(t *testing.T) {
testVersion("this should be unknown"),
versionUnknown,
},
{
testVersion("go1.21-20230101-RC01 cl/1234567 +abc1234"),
"1.21.0-20230101-RC01",
},
} {
version = tst.v
got := goVersion()
Expand Down

0 comments on commit fd7bca0

Please sign in to comment.