@@ -48,14 +48,14 @@ func TestNewGitIdentifier(t *testing.T) {
4848 expected : GitIdentifier {
4949 Remote : "git://github.com/user/repo.git" ,
5050 Ref : "mybranch" ,
51- Subdir : "mydir/mysubdir/ " ,
51+ Subdir : "mydir/mysubdir" ,
5252 },
5353 },
5454 {
5555 url : "git://github.com/user/repo.git#:mydir/mysubdir/" ,
5656 expected : GitIdentifier {
5757 Remote : "git://github.com/user/repo.git" ,
58- Subdir : "mydir/mysubdir/ " ,
58+ Subdir : "mydir/mysubdir" ,
5959 },
6060 },
6161 {
@@ -69,7 +69,7 @@ func TestNewGitIdentifier(t *testing.T) {
6969 expected : GitIdentifier {
7070 Remote : "https://github.com/user/repo.git" ,
7171 Ref : "mybranch" ,
72- Subdir : "mydir/mysubdir/ " ,
72+ Subdir : "mydir/mysubdir" ,
7373 },
7474 },
7575 {
@@ -83,7 +83,7 @@ func TestNewGitIdentifier(t *testing.T) {
8383 expected : GitIdentifier {
8484 Remote : "git@github.com:user/repo.git" ,
8585 Ref : "mybranch" ,
86- Subdir : "mydir/mysubdir/ " ,
86+ Subdir : "mydir/mysubdir" ,
8787 },
8888 },
8989 {
@@ -97,15 +97,78 @@ func TestNewGitIdentifier(t *testing.T) {
9797 expected : GitIdentifier {
9898 Remote : "ssh://github.com/user/repo.git" ,
9999 Ref : "mybranch" ,
100- Subdir : "mydir/mysubdir/ " ,
100+ Subdir : "mydir/mysubdir" ,
101101 },
102102 },
103103 {
104104 url : "ssh://foo%40barcorp.com@github.com/user/repo.git#mybranch:mydir/mysubdir/" ,
105105 expected : GitIdentifier {
106106 Remote : "ssh://foo%40barcorp.com@github.com/user/repo.git" ,
107107 Ref : "mybranch" ,
108- Subdir : "mydir/mysubdir/" ,
108+ Subdir : "mydir/mysubdir" ,
109+ },
110+ },
111+ {
112+ url : "https://github.com/user/repo.git#main:../../escape" ,
113+ expected : GitIdentifier {
114+ Remote : "https://github.com/user/repo.git" ,
115+ Ref : "main" ,
116+ Subdir : "escape" ,
117+ },
118+ },
119+ {
120+ url : "https://github.com/user/repo.git#main:dir/../../escape" ,
121+ expected : GitIdentifier {
122+ Remote : "https://github.com/user/repo.git" ,
123+ Ref : "main" ,
124+ Subdir : "escape" ,
125+ },
126+ },
127+ {
128+ url : "https://github.com/user/repo.git#main:/absolute/path" ,
129+ expected : GitIdentifier {
130+ Remote : "https://github.com/user/repo.git" ,
131+ Ref : "main" ,
132+ Subdir : "absolute/path" ,
133+ },
134+ },
135+ {
136+ url : "https://github.com/user/repo.git#main:../" ,
137+ expected : GitIdentifier {
138+ Remote : "https://github.com/user/repo.git" ,
139+ Ref : "main" ,
140+ },
141+ },
142+ {
143+ url : "ssh://github.com/user/repo.git#main:../../escape" ,
144+ expected : GitIdentifier {
145+ Remote : "ssh://github.com/user/repo.git" ,
146+ Ref : "main" ,
147+ Subdir : "escape" ,
148+ },
149+ },
150+ {
151+ url : "ssh://github.com/user/repo.git#main:/absolute/path" ,
152+ expected : GitIdentifier {
153+ Remote : "ssh://github.com/user/repo.git" ,
154+ Ref : "main" ,
155+ Subdir : "absolute/path" ,
156+ },
157+ },
158+ {
159+ url : "git@github.com:user/repo.git#main:../../escape" ,
160+ expected : GitIdentifier {
161+ Remote : "git@github.com:user/repo.git" ,
162+ Ref : "main" ,
163+ Subdir : "escape" ,
164+ },
165+ },
166+ {
167+ url : "git@github.com:user/repo.git#main:/absolute/path" ,
168+ expected : GitIdentifier {
169+ Remote : "git@github.com:user/repo.git" ,
170+ Ref : "main" ,
171+ Subdir : "absolute/path" ,
109172 },
110173 },
111174 }
0 commit comments