Skip to content

Commit

Permalink
refactor: keep both headers
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 16, 2023
1 parent 8fb846e commit a82f755
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion files/multifilereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {

header.Set("Content-Type", contentType)
if rf, ok := entry.Node().(FileInfo); ok {
header.Set("abspath", url.QueryEscape(rf.AbsPath()))
header.Set("abspath", rf.AbsPath())
header.Set("abspath-percent", url.QueryEscape(rf.AbsPath()))
}

_, err := mfr.mpWriter.CreatePart(header)
Expand Down
13 changes: 9 additions & 4 deletions files/multipartfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,19 @@ func (w *multipartWalker) nextFile() (Node, error) {

return NewLinkFile(string(out), nil), nil
default:
abspath, err := url.QueryUnescape(part.Header.Get("abspath"))
if err != nil {
return nil, err
var absPath string
if absPathEncoded := part.Header.Get("abspath-percent"); absPathEncoded != "" {
absPath, err = url.QueryUnescape(absPathEncoded)
if err != nil {
return nil, err
}

Check warning on line 108 in files/multipartfile.go

View check run for this annotation

Codecov / codecov/patch

files/multipartfile.go#L105-L108

Added lines #L105 - L108 were not covered by tests
} else {
absPath = part.Header.Get("abspath")
}

return &ReaderFile{
reader: part,
abspath: abspath,
abspath: absPath,
}, nil
}
}
Expand Down

0 comments on commit a82f755

Please sign in to comment.