diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2025-07-17 23:51:22 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2025-07-17 23:51:22 +0100 |
| commit | c7c3e1437bd92982937ba6ce6b46a002077912c0 (patch) | |
| tree | e699bbf9216b92068af5373558bfb1fb71c23acd /pkg | |
| parent | d2f932f27e2009cf9a621520ad35598d9841fb03 (diff) | |
Force trailing slash if directory
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/site/fs.go | 4 |
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 { |
