mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Ensure RawPath match Path when resolving reference
Signed-off-by: Mathieu Parent <math.parent@gmail.com>
This commit is contained in:
parent
179f90151d
commit
dbb4eb6b75
2 changed files with 10 additions and 3 deletions
|
|
@ -286,7 +286,8 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName,
|
|||
// ResolveReferenceURL resolves refURL relative to baseURL.
|
||||
// If refURL is absolute, it simply returns refURL.
|
||||
func ResolveReferenceURL(baseURL, refURL string) (string, error) {
|
||||
parsedBaseURL, err := url.Parse(baseURL)
|
||||
// We need a trailing slash for ResolveReference to work, but make sure there isn't already one
|
||||
parsedBaseURL, err := url.Parse(strings.TrimSuffix(baseURL, "/") + "/")
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to parse %s as URL", baseURL)
|
||||
}
|
||||
|
|
@ -296,8 +297,6 @@ func ResolveReferenceURL(baseURL, refURL string) (string, error) {
|
|||
return "", errors.Wrapf(err, "failed to parse %s as URL", refURL)
|
||||
}
|
||||
|
||||
// We need a trailing slash for ResolveReference to work, but make sure there isn't already one
|
||||
parsedBaseURL.Path = strings.TrimSuffix(parsedBaseURL.Path, "/") + "/"
|
||||
return parsedBaseURL.ResolveReference(parsedRefURL).String(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -400,4 +400,12 @@ func TestResolveReferenceURL(t *testing.T) {
|
|||
if chartURL != "https://charts.helm.sh/stable/nginx-0.2.0.tgz" {
|
||||
t.Errorf("%s", chartURL)
|
||||
}
|
||||
|
||||
chartURL, err = ResolveReferenceURL("http://localhost:8123/charts%2fwith%2fescaped%2fslash", "nginx-0.2.0.tgz")
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
}
|
||||
if chartURL != "http://localhost:8123/charts%2fwith%2fescaped%2fslash/nginx-0.2.0.tgz" {
|
||||
t.Errorf("%s", chartURL)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue