preserve url encoded path in helm repo
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
parent
a302c71c57
commit
64139e7ec1
|
|
@ -47,10 +47,16 @@ func NormalizeURL(repositoryURL string) (string, error) {
|
||||||
|
|
||||||
if u.Scheme == helmreg.OCIScheme {
|
if u.Scheme == helmreg.OCIScheme {
|
||||||
u.Path = strings.TrimRight(u.Path, "/")
|
u.Path = strings.TrimRight(u.Path, "/")
|
||||||
|
// we perform the same operation on u.RawPath so that it will be a valid encoding
|
||||||
|
// of u.Path. This allows u.EscapedPath() (which is used in computing u.String()) to return
|
||||||
|
// the correct value when the path is url encoded.
|
||||||
|
// ref: https://pkg.go.dev/net/url#URL.EscapedPath
|
||||||
|
u.RawPath = strings.TrimRight(u.RawPath, "/")
|
||||||
return u.String(), nil
|
return u.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
u.Path = strings.TrimRight(u.Path, "/") + "/"
|
u.Path = strings.TrimRight(u.Path, "/") + "/"
|
||||||
|
u.RawPath = strings.TrimRight(u.RawPath, "/") + "/"
|
||||||
return u.String(), nil
|
return u.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,16 @@ func TestNormalizeURL(t *testing.T) {
|
||||||
url: "http://example.com/?st=pr",
|
url: "http://example.com/?st=pr",
|
||||||
want: "http://example.com/?st=pr",
|
want: "http://example.com/?st=pr",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "url with encoded path",
|
||||||
|
url: "http://example.com/next%2Fpath",
|
||||||
|
want: "http://example.com/next%2Fpath/",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "url with encoded path and slash",
|
||||||
|
url: "http://example.com/next%2Fpath/",
|
||||||
|
want: "http://example.com/next%2Fpath/",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "empty url",
|
name: "empty url",
|
||||||
url: "",
|
url: "",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue