Skip to content

Commit

Permalink
🐞 panic in fs.go #824 (#825)
Browse files Browse the repository at this point in the history
Co-authored-by: wernerr <rene.werner@verivox.com>
  • Loading branch information
ReneWerner87 and wernerr committed Jun 4, 2020
1 parent 33b3cb2 commit 853abb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func ServeFile(ctx *RequestCtx, path string) {
})
if len(path) == 0 || path[0] != '/' {
// extend relative path to absolute path
hasTrailingSlash := path[len(path) - 1] == '/'
hasTrailingSlash := len(path) > 0 && path[len(path)-1] == '/'
var err error
if path, err = filepath.Abs(path); err != nil {
ctx.Logger().Printf("cannot resolve path %q to absolute file path: %s", path, err)
Expand Down Expand Up @@ -688,7 +688,7 @@ func (h *fsHandler) handleRequest(ctx *RequestCtx) {
} else {
path = ctx.Path()
}
hasTrailingSlash := path[len(path) - 1] == '/'
hasTrailingSlash := len(path) > 0 && path[len(path)-1] == '/'
path = stripTrailingSlashes(path)

if n := bytes.IndexByte(path, 0); n >= 0 {
Expand Down

0 comments on commit 853abb3

Please sign in to comment.