Skip to content

Commit

Permalink
fileserver: Fix "go up" links in browse listings (closes #3942)
Browse files Browse the repository at this point in the history
At some point we changed how paths are represented down the function calls of browse listings and forgot to update the canGoUp logic. I think this is right? It's simpler now.
  • Loading branch information
mholt committed Dec 30, 2020
1 parent 38a83ca commit d8bcf5b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/caddyhttp/fileserver/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ func (fsrv *FileServer) loadDirectoryContents(dir *os.File, root, urlPath string
return browseListing{}, err
}

// determine if user can browse up another folder
curPathDir := path.Dir(strings.TrimSuffix(urlPath, "/"))
canGoUp := strings.HasPrefix(curPathDir, root)
// user can presumably browse "up" to parent folder if path is longer than "/"
canGoUp := len(urlPath) > 1

return fsrv.directoryListing(files, canGoUp, root, urlPath, repl), nil
}
Expand Down

0 comments on commit d8bcf5b

Please sign in to comment.