bug-fix: handle complex file names

Signed-off-by: Adam Martin <adam.martin@rancherfederal.com>
This commit is contained in:
Adam Martin
2024-02-15 19:55:38 -05:00
parent e15c8d54fa
commit dbcfe13fb6
2 changed files with 7 additions and 1 deletions

View File

@@ -25,6 +25,11 @@ func (h Http) Name(u *url.URL) string {
return ""
}
name, _ := url.PathUnescape(u.String())
if err != nil {
return ""
}
contentType := resp.Header.Get("Content-Type")
for _, v := range strings.Split(contentType, ",") {
t, _, err := mime.ParseMediaType(v)
@@ -36,7 +41,7 @@ func (h Http) Name(u *url.URL) string {
}
// TODO: Not this
return filepath.Base(u.String())
return filepath.Base(name)
}
func (h Http) Open(ctx context.Context, u *url.URL) (io.ReadCloser, error) {