Skip to content

Commit 639230a

Browse files
committed
GitLab can use both Path and RawPath
1 parent 900b5de commit 639230a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cmd/clusterctl/client/repository/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func repositoryFactory(ctx context.Context, providerConfig config.Provider, conf
186186
}
187187

188188
// if the url is a GitLab repository
189-
if strings.HasPrefix(rURL.Host, gitlabHostPrefix) && strings.HasPrefix(rURL.RawPath, gitlabPackagesAPIPrefix) {
189+
if strings.HasPrefix(rURL.Host, gitlabHostPrefix) && strings.HasPrefix(rURL.EscapedPath(), gitlabPackagesAPIPrefix) {
190190
repo, err := NewGitLabRepository(providerConfig, configVariablesClient)
191191
if err != nil {
192192
return nil, errors.Wrap(err, "error creating the GitLab repository client")

cmd/clusterctl/client/repository/repository_gitlab.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ func NewGitLabRepository(providerConfig config.Provider, configVariablesClient c
6666
return nil, errors.Wrap(err, "invalid url")
6767
}
6868

69-
urlSplit := strings.Split(strings.TrimPrefix(rURL.RawPath, "/"), "/")
69+
urlSplit := strings.Split(strings.TrimPrefix(rURL.EscapedPath(), "/"), "/")
7070

7171
// Check if the url is a Gitlab repository
7272
if rURL.Scheme != httpsScheme ||
7373
len(urlSplit) != 9 ||
74-
!strings.HasPrefix(rURL.RawPath, gitlabPackagesAPIPrefix) ||
74+
!strings.HasPrefix(rURL.EscapedPath(), gitlabPackagesAPIPrefix) ||
7575
urlSplit[4] != gitlabPackagesAPIPackages ||
7676
urlSplit[5] != gitlabPackagesAPIGeneric {
7777
return nil, errors.New("invalid url: a GitLab repository url should be in the form https://{host}/api/v4/projects/{projectSlug}/packages/generic/{packageName}/{defaultVersion}/{componentsPath}")

0 commit comments

Comments
 (0)