From 54f35701a2bd5cb7ec0628ca9789047072c073db Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 9 Mar 2021 15:54:54 +0000 Subject: [PATCH] fix: archive contains parent path on Windows --- http/raw.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/http/raw.go b/http/raw.go index 10f07bcd..85c180ad 100644 --- a/http/raw.go +++ b/http/raw.go @@ -108,8 +108,6 @@ var rawHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) }) func addFile(ar archiver.Writer, d *data, path, commonPath string) error { - // Checks are always done with paths with "/" as path separator. - path = strings.Replace(path, "\\", "/", -1) if !d.Check(path) { return nil } @@ -134,7 +132,7 @@ func addFile(ar archiver.Writer, d *data, path, commonPath string) error { if path != commonPath { filename := strings.TrimPrefix(path, commonPath) - filename = strings.TrimPrefix(filename, "/") + filename = strings.TrimPrefix(filename, string(filepath.Separator)) err = ar.Write(archiver.File{ FileInfo: archiver.FileInfo{ FileInfo: info, @@ -188,7 +186,7 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files. } defer ar.Close() - commonDir := fileutils.CommonPrefix('/', filenames...) + commonDir := fileutils.CommonPrefix(filepath.Separator, filenames...) for _, fname := range filenames { err = addFile(ar, d, fname, commonDir)