File tree 2 files changed +41
-1
lines changed
2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -804,8 +804,12 @@ func DefaultSupportLinks(docsURL string) []LinkConfig {
804
804
}
805
805
}
806
806
807
+ func removeTrailingVersionInfo (v string ) string {
808
+ return strings .Split (strings .Split (v , "-" )[0 ], "+" )[0 ]
809
+ }
810
+
807
811
func DefaultDocsURL () string {
808
- version := strings . Split (buildinfo .Version (), "-" )[ 0 ]
812
+ version := removeTrailingVersionInfo (buildinfo .Version ())
809
813
if version == "v0.0.0" {
810
814
return "https://coder.com/docs"
811
815
}
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments