Skip to content

Commit

Permalink
Fix: Base URL query string not retained for chart download
Browse files Browse the repository at this point in the history
  • Loading branch information
janeczku authored and bashofmann committed Dec 15, 2020
1 parent 83b502d commit 4b6e7bf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/catalogv2/http/download.go
Expand Up @@ -36,11 +36,13 @@ func Icon(secret *corev1.Secret, repoURL string, caBundle []byte, insecureSkipTL
return nil, "", err
}
if !u.IsAbs() {
base, err := url.Parse(strings.TrimSuffix(repoURL, "/") + "/")
base, err := url.Parse(repoURL)
if err != nil {
return nil, "", err
}
base.Path = strings.TrimSuffix(base.Path, "/") + "/"
u = base.ResolveReference(u)
u.RawQuery = base.RawQuery
}

resp, err := client.Get(u.String())
Expand Down Expand Up @@ -76,11 +78,17 @@ func Chart(secret *corev1.Secret, repoURL string, caBundle []byte, insecureSkipT
return nil, err
}
if !u.IsAbs() {
base, err := url.Parse(strings.TrimSuffix(repoURL, "/") + "/")
base, err := url.Parse(repoURL)
if err != nil {
return nil, err
}
// Prevent ResolveReference from stripping the last element
// of the path by ensuring it has a trailing slash
base.Path = strings.TrimSuffix(base.Path, "/") + "/"
u = base.ResolveReference(u)
// Retain the query string of the repository URL as it might
// contain an access credential.
u.RawQuery = base.RawQuery
}

resp, err := client.Get(u.String())
Expand Down

0 comments on commit 4b6e7bf

Please sign in to comment.