Skip to content

Commit

Permalink
fix: empty archive name on directory download
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiresviana committed Mar 26, 2021
1 parent 59f9964 commit 2697093
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions http/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.

commonDir := fileutils.CommonPrefix(filepath.Separator, filenames...)

var name string
if len(filenames) > 1 {
name = "_" + filepath.Base(commonDir)
} else {
name := filepath.Base(commonDir)
if name == "." || name == "" || name == string(filepath.Separator) {
name = file.Name
}
if name == "." || name == "" {
name = "archive"
// Prefix used to distinguish a filelist generated
// archive from the full directory archive
if len(filenames) > 1 {
name = "_" + name
}
name += extension
w.Header().Set("Content-Disposition", "attachment; filename*=utf-8''"+url.PathEscape(name))
Expand Down

0 comments on commit 2697093

Please sign in to comment.