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 <61021968+bcpeinhardt@users.noreply.github.com>
1 parent 5133315 commit 971b1a8

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

codersdk/deployment.go

Lines changed: 5 additions & 1 deletion
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

Lines changed: 36 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy