Make it always redirect to dir/ for directories otherwise it breaks HTML relatives
Signed-off-by: arzumify <jliwin98@danwin1210.de>
This commit is contained in:
parent
b0fb00d7fd
commit
65de87137d
5
main.go
5
main.go
|
@ -385,6 +385,11 @@ func newFileServer(root string, directoryListing bool) http.Handler {
|
|||
_, err := os.Stat(filepath.Join(root, filepath.FromSlash(r.URL.Path), "index.html"))
|
||||
if err != nil {
|
||||
if directoryListing {
|
||||
// Check if the path ends with a slash
|
||||
if !strings.HasSuffix(r.URL.Path, "/") {
|
||||
http.Redirect(w, r, r.URL.Path+"/", 301)
|
||||
return
|
||||
}
|
||||
listDirectory(w, r, root)
|
||||
} else {
|
||||
serverError(w, 403)
|
||||
|
|
Loading…
Reference in New Issue