From 31ea2f650b8faac47125a82ba1d45b7ea1e066fa Mon Sep 17 00:00:00 2001 From: Thomas Miceli Date: Mon, 20 Mar 2023 13:49:28 +0100 Subject: [PATCH] Fix naming file on edit --- internal/web/gist.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/web/gist.go b/internal/web/gist.go index 24364f6..ac88eca 100644 --- a/internal/web/gist.go +++ b/internal/web/gist.go @@ -209,12 +209,14 @@ func processCreate(ctx echo.Context) error { } dto.Files = make([]models.FileDTO, 0) + fileCounter := 0 for i := 0; i < len(ctx.Request().PostForm["content"]); i++ { name := ctx.Request().PostForm["name"][i] content := ctx.Request().PostForm["content"][i] if name == "" { - name = "gistfile" + strconv.Itoa(i+1) + ".txt" + fileCounter += 1 + name = "gistfile" + strconv.Itoa(fileCounter) + ".txt" } escapedValue, err := url.QueryUnescape(content)