flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit e286a19d517d41e50443c3885ce8695878da32c0
parent 3d63a8ce4b80ae8cd81bff62ef03e4d4ea8b436f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat,  5 Dec 2020 17:57:15 -0800

Fix line feeds in saved file

Diffstat:
Mhttp.go | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/http.go b/http.go @@ -134,7 +134,11 @@ func editFileHandler(w http.ResponseWriter, r *http.Request) { } else if r.Method == "POST" { // get post body r.ParseForm() - fileBytes := []byte(r.Form.Get("file_text")) + fileText := r.Form.Get("file_text") + // Web form by default gives us CR LF newlines. + // Unix files use just LF + fileText = strings.ReplaceAll(fileText, "\r\n", "\n") + fileBytes := []byte(fileText) err := checkIfValidFile(filePath, fileBytes) if err != nil { log.Println(err)