Fix empty filename when Content-Disposition header is missing in /dl command

Add filenameFromURL helper to extract filename from URL path when
Content-Disposition header is empty or not present. This fixes the issue
where direct link downloads fail due to empty filename.

Co-authored-by: krau <71133316+krau@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-28 08:57:05 +00:00
parent cfcca79a12
commit 943ad190e6
3 changed files with 112 additions and 1 deletions

View File

@@ -45,10 +45,14 @@ func (t *Task) Execute(ctx context.Context) error {
fetchedTotalBytes.Add(resp.ContentLength)
file.Size = resp.ContentLength
if name := resp.Header.Get("Content-Disposition"); name != "" {
// Set file name
// Set file name from Content-Disposition header
filename := parseFilename(name)
file.Name = filename
}
// Fallback: extract filename from URL if Content-Disposition is empty
if file.Name == "" {
file.Name = filenameFromURL(file.URL)
}
return nil
})