File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ class GitlabRepositoryProvider extends RepositoryProvider {
88
88
// https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository
89
89
//
90
90
final ref = revision ?: getDefaultBranch()
91
- final encodedPath = URLEncoder . encode(path,' utf-8' )
91
+ final encodedPath = URLEncoder . encode(path. stripStart( ' / ' ) ,' utf-8' )
92
92
return " ${ config.endpoint} /api/v4/projects/${ getProjectName()} /repository/files/${ encodedPath} ?ref=${ ref} "
93
93
}
94
94
Original file line number Diff line number Diff line change @@ -121,5 +121,15 @@ class GitlabRepositoryProviderTest extends Specification {
121
121
new GitlabRepositoryProvider (' pditommaso/hello' , obj)
122
122
.getContentUrl(' conf/extra.conf' ) == ' https://gitlab.com/api/v4/projects/pditommaso%2Fhello/repository/files/conf%2Fextra.conf?ref=master'
123
123
124
+
125
+ and : // should strip leading slashes
126
+ new GitlabRepositoryProvider (' pditommaso/hello' , obj)
127
+ .getContentUrl(' /main.nf' ) == ' https://gitlab.com/api/v4/projects/pditommaso%2Fhello/repository/files/main.nf?ref=master'
128
+
129
+ and :
130
+ new GitlabRepositoryProvider (' pditommaso/hello' , obj)
131
+ .getContentUrl(' //conf/extra.conf' ) == ' https://gitlab.com/api/v4/projects/pditommaso%2Fhello/repository/files/conf%2Fextra.conf?ref=master'
132
+
133
+
124
134
}
125
135
}
You can’t perform that action at this time.
0 commit comments