From 144452f798f6a833156b9d610412e53c9b713a96 Mon Sep 17 00:00:00 2001 From: arzumify Date: Sun, 3 Nov 2024 12:13:34 +0000 Subject: [PATCH] Fix the directory listing, once and for all Signed-off-by: arzumify --- main.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/main.go b/main.go index 6c17475..de3e0da 100644 --- a/main.go +++ b/main.go @@ -288,7 +288,7 @@ func listDirectory(w http.ResponseWriter, r *http.Request, root string) { return } for _, entry := range entries { - _, err = w.Write([]byte("
  • " + entry.Name() + "
  • ")) + _, err = w.Write([]byte("
  • " + entry.Name() + "
  • ")) if err != nil { serverError(w, 500) slog.Error("Error writing directory listing: " + err.Error()) @@ -385,11 +385,6 @@ 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)