fix: Upload text files other than plain text
All checks were successful
/ pre-commit (push) Successful in 1m23s

Fixes #23

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-09-10 07:02:48 +02:00
parent af5baa999c
commit 401397241b
Signed by: jriou
GPG key ID: 9A099EDA51316854

View file

@ -246,7 +246,7 @@ func (h *CreateNoteWithFormHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
} }
h.logger.Debug("checking file content type") h.logger.Debug("checking file content type")
if handler.Header.Get("Content-Type") != "text/plain" { if !strings.HasPrefix(handler.Header.Get("Content-Type"), "text/") {
h.PageData.Err = fmt.Errorf("text file expected (got %s)", handler.Header.Get("Content-Type")) h.PageData.Err = fmt.Errorf("text file expected (got %s)", handler.Header.Get("Content-Type"))
h.Templates.ExecuteTemplate(w, templateName, h.PageData) h.Templates.ExecuteTemplate(w, templateName, h.PageData)
return return