Don't serve files for URLs with trailing slashes.

Fixes: https://codeberg.org/git-pages/git-pages/issues/205
This commit is contained in:
miyuko
2026-06-19 02:25:28 +01:00
committed by Catherine
parent f620381551
commit 4cc8d58548
+5 -1
View File
@@ -298,7 +298,8 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
reader := io.ReadSeeker(nil)
mtime := time.Time{}
for {
entryPath, _ = strings.CutSuffix(entryPath, "/")
endsInSlash := false
entryPath, endsInSlash = strings.CutSuffix(entryPath, "/")
entryPath, err = ExpandSymlinks(manifest, entryPath)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
@@ -306,6 +307,9 @@ func getPage(w http.ResponseWriter, r *http.Request) error {
return err
}
entry = manifest.Contents[entryPath]
if entry != nil && IsEntryRegularFile(entry) && endsInSlash {
entry = nil
}
if !appliedRedirect {
redirectKind := RedirectAny
if entry != nil && entry.GetType() != Type_InvalidEntry {