mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-06-09 17:39:59 +08:00
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:
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user