@@ -35,11 +35,56 @@ func TestDefaultWorkspaceFolder(t *testing.T) {
35
35
gitURL :
"https://username:[email protected] /coder/envbuilder.git" ,
36
36
expected : "/workspaces/envbuilder" ,
37
37
},
38
+ {
39
+ name : "trailing" ,
40
+ gitURL : "https://github.com/coder/envbuilder.git/" ,
41
+ expected : "/workspaces/envbuilder" ,
42
+ },
43
+ {
44
+ name : "trailing-x2" ,
45
+ gitURL : "https://github.com/coder/envbuilder.git//" ,
46
+ expected : "/workspaces/envbuilder" ,
47
+ },
48
+ {
49
+ name : "no .git" ,
50
+ gitURL : "https://github.com/coder/envbuilder" ,
51
+ expected : "/workspaces/envbuilder" ,
52
+ },
53
+ {
54
+ name : "trailing no .git" ,
55
+ gitURL : "https://github.com/coder/envbuilder/" ,
56
+ expected : "/workspaces/envbuilder" ,
57
+ },
38
58
{
39
59
name : "fragment" ,
40
60
gitURL : "https://github.com/coder/envbuilder.git#feature-branch" ,
41
61
expected : "/workspaces/envbuilder" ,
42
62
},
63
+ {
64
+ name : "fragment-trailing" ,
65
+ gitURL : "https://github.com/coder/envbuilder.git/#refs/heads/feature-branch" ,
66
+ expected : "/workspaces/envbuilder" ,
67
+ },
68
+ {
69
+ name : "fragment-trailing no .git" ,
70
+ gitURL : "https://github.com/coder/envbuilder/#refs/heads/feature-branch" ,
71
+ expected : "/workspaces/envbuilder" ,
72
+ },
73
+ {
74
+ name : "space" ,
75
+ gitURL : "https://github.com/coder/env%20builder.git" ,
76
+ expected : "/workspaces/env builder" ,
77
+ },
78
+ {
79
+ name : "Unix path" ,
80
+ gitURL : "/repo" ,
81
+ expected : "/workspaces/repo" ,
82
+ },
83
+ {
84
+ name : "Unix subpath" ,
85
+ gitURL : "/path/to/repo" ,
86
+ expected : "/workspaces/repo" ,
87
+ },
43
88
{
44
89
name : "empty" ,
45
90
gitURL : "" ,
@@ -65,6 +110,18 @@ func TestDefaultWorkspaceFolder(t *testing.T) {
65
110
name : "website URL" ,
66
111
invalidURL : "www.google.com" ,
67
112
},
113
+ {
114
+ name : "Unix root" ,
115
+ invalidURL : "/" ,
116
+ },
117
+ {
118
+ name : "Path consists entirely of slash" ,
119
+ invalidURL : "//" ,
120
+ },
121
+ {
122
+ name : "Git URL with no path" ,
123
+ invalidURL : "http://127.0.0.1:41073" ,
124
+ },
68
125
}
69
126
for _ , tt := range invalidTests {
70
127
t .Run (tt .name , func (t * testing.T ) {
0 commit comments