Address code review feedback: add validation and improve error handling

Co-authored-by: krau <71133316+krau@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-28 08:59:56 +00:00
parent 943ad190e6
commit 6fbde66415
2 changed files with 9 additions and 1 deletions

View File

@@ -49,10 +49,13 @@ func (t *Task) Execute(ctx context.Context) error {
filename := parseFilename(name)
file.Name = filename
}
// Fallback: extract filename from URL if Content-Disposition is empty
// Fallback: extract filename from URL if no filename was determined from Content-Disposition
if file.Name == "" {
file.Name = filenameFromURL(file.URL)
}
if file.Name == "" {
return fmt.Errorf("could not determine filename for %s", file.URL)
}
return nil
})

View File

@@ -65,6 +65,11 @@ func TestFilenameFromURL(t *testing.T) {
url: "https://cdn.example.com/a/b/c/d/e/video.mkv",
expected: "video.mkv",
},
{
name: "malformed url with invalid characters",
url: "://invalid url",
expected: "",
},
}
for _, tt := range tests {