Fixes #723 - Add no-store header for embedded js (#724)

This commit is contained in:
Marcel Herrguth
2026-06-19 19:28:32 +02:00
committed by GitHub
parent 9d9b54a5e1
commit 499f9c67b9
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -191,6 +191,7 @@ func GistJs(ctx *context.Context) error {
if err != nil {
return ctx.ErrorRes(500, "Error escaping JavaScript content", err)
}
ctx.Response().Header().Set("Cache-Control", "no-store")
ctx.Response().Header().Set("Content-Type", "text/javascript")
return ctx.PlainText(200, js)
}
+7
View File
@@ -384,6 +384,13 @@ func TestGistJsSingleFile(t *testing.T) {
assert.Contains(t, string(body), "prefers-color-scheme")
})
t.Run("NoCacheHeader", func(t *testing.T) {
_, _, username, identifier := s.CreateGist(t, "0")
resp := s.Request(t, "GET", "/"+username+"/"+identifier+".js", nil, 200)
assert.Equal(t, "no-store", resp.Header.Get("Cache-Control"))
})
t.Run("PrivateGist", func(t *testing.T) {
_, _, username, identifier := s.CreateGist(t, "2")