From a5e164cd94b4d63c8ff37ac731c38f5102a31591 Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Sat, 14 Oct 2023 10:48:11 +0200 Subject: [PATCH 1/2] Fix invalid JSON in /version endpoint response --- api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.go b/api.go index d639749f..43f97ed0 100644 --- a/api.go +++ b/api.go @@ -477,7 +477,7 @@ func (server *ApiServer) Version(response http.ResponseWriter, request *http.Req log := zerolog.Ctx(request.Context()) response.Header().Set("Content-Type", "application/json;charset=utf-8") - version := fmt.Sprintf(`{"version": "%s"}\n`, Version) + version := fmt.Sprintf("{\"version\": \"%s\"}\n", Version) _, err := response.Write([]byte(version)) if err != nil { log.Warn().Err(err).Msg("Version: Failed to write response to client") From 56c3f4b01a5a9a904e3b399247d1d405f68499ac Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Wed, 25 Oct 2023 15:50:08 +0200 Subject: [PATCH 2/2] Fix test --- api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_test.go b/api_test.go index 322cfe07..61e99971 100644 --- a/api_test.go +++ b/api_test.go @@ -1103,7 +1103,7 @@ func TestVersionEndpointReturnsVersion(t *testing.T) { t.Fatal("Unable to read body from response") } - if string(body) != `{"version": "git"}\n` { + if string(body) != "{\"version\": \"git\"}\n" { t.Fatal("Expected to return Version from /version, got:", string(body)) } })