Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 971b1a8

Browse files
sreyabcpeinhardt
andauthored
fix: fix bug with trailing version info not being properly stripped (… (#15223)
#14963) Fixes a bug where excess version info was not being stripped properly from documentation links. Co-authored-by: Benjamin Peinhardt <[email protected]>
1 parent 5133315 commit 971b1a8

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

codersdk/deployment.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,12 @@ func DefaultSupportLinks(docsURL string) []LinkConfig {
804804
}
805805
}
806806

807+
func removeTrailingVersionInfo(v string) string {
808+
return strings.Split(strings.Split(v, "-")[0], "+")[0]
809+
}
810+
807811
func DefaultDocsURL() string {
808-
version := strings.Split(buildinfo.Version(), "-")[0]
812+
version := removeTrailingVersionInfo(buildinfo.Version())
809813
if version == "v0.0.0" {
810814
return "https://coder.com/docs"
811815
}

codersdk/deployment_internal_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package codersdk
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestRemoveTrailingVersionInfo(t *testing.T) {
10+
t.Parallel()
11+
12+
testCases := []struct {
13+
Version string
14+
ExpectedAfterStrippingInfo string
15+
}{
16+
{
17+
Version: "v2.16.0+683a720",
18+
ExpectedAfterStrippingInfo: "v2.16.0",
19+
},
20+
{
21+
Version: "v2.16.0-devel+683a720",
22+
ExpectedAfterStrippingInfo: "v2.16.0",
23+
},
24+
{
25+
Version: "v2.16.0+683a720-devel",
26+
ExpectedAfterStrippingInfo: "v2.16.0",
27+
},
28+
}
29+
30+
for _, tc := range testCases {
31+
tc := tc
32+
33+
stripped := removeTrailingVersionInfo(tc.Version)
34+
require.Equal(t, tc.ExpectedAfterStrippingInfo, stripped)
35+
}
36+
}

0 commit comments

Comments
 (0)