Skip to content

Commit

Permalink
Merge pull request #39 from ant1k9/master
Browse files Browse the repository at this point in the history
Fall back to filename from URL when don't have it in the header
  • Loading branch information
melbahja authored May 8, 2022
2 parents d160006 + 5f491ce commit eac659f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dist/
coverage.out
*.dat
*.output
7 changes: 4 additions & 3 deletions download.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,13 @@ func (d *Download) Path() string {
// Set the default path
if d.path == "" {

d.path = GetFilename(d.URL) // default case
if d.Dest != "" {
d.path = d.Dest
} else if d.unsafeName != "" {
d.path = getNameFromHeader(d.unsafeName)
} else {
d.path = GetFilename(d.URL)
if path := getNameFromHeader(d.unsafeName); path != "" {
d.path = path
}
}
d.path = filepath.Join(d.Dir, d.path)
}
Expand Down

0 comments on commit eac659f

Please sign in to comment.