fix(blogo,gitea): trim trailing and leading slashes in request path

This commit is contained in:
Guz
2025-01-08 16:48:27 -03:00
parent e1c607c909
commit e3825fa88d

View File

@@ -70,7 +70,9 @@ func (b *Blogo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
f, err := b.files.Open(r.URL.Path)
path := strings.Trim(r.URL.Path, "/")
f, err := b.files.Open(path)
if errors.Is(err, fs.ErrNotExist) {
w.WriteHeader(http.StatusNotFound)
_, _ = w.Write([]byte(err.Error()))