aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/site/fs.go
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.net>2025-07-17 23:51:22 +0100
committerLeonardo Bishop <me@leonardobishop.net>2025-07-17 23:51:22 +0100
commitc7c3e1437bd92982937ba6ce6b46a002077912c0 (patch)
treee699bbf9216b92068af5373558bfb1fb71c23acd /pkg/site/fs.go
parentd2f932f27e2009cf9a621520ad35598d9841fb03 (diff)
Force trailing slash if directory
Diffstat (limited to 'pkg/site/fs.go')
-rw-r--r--pkg/site/fs.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/site/fs.go b/pkg/site/fs.go
index 6a3b1d6..11b36cf 100644
--- a/pkg/site/fs.go
+++ b/pkg/site/fs.go
@@ -50,6 +50,10 @@ func (fs *SiteFileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
if info.IsDir() {
+ if !strings.HasSuffix(path, "/") {
+ http.Redirect(w, r, path+"/", http.StatusTemporaryRedirect)
+ return
+ }
indexPath := filepath.Join(path, "index.html")
if file, err = fs.root.Open(indexPath); os.IsNotExist(err) {
if fs.siteConfig.Flags&config.FlagIndex == 0 {