diff --git a/policy.go b/policy.go index 15e62c1..61fb15c 100644 --- a/policy.go +++ b/policy.go @@ -68,7 +68,7 @@ func (p *policy) loadConfig(config Config) { stsSub = "; includeSubdomains" } if config.STSPreload { - stsSub = "; preload" + stsSub += "; preload" } // TODO // "max-age=%d%s" refactor diff --git a/secure_test.go b/secure_test.go index f581a1d..7665d3b 100644 --- a/secure_test.go +++ b/secure_test.go @@ -285,6 +285,19 @@ func TestStsHeaderWithSubdomain(t *testing.T) { assert.Equal(t, "max-age=315360000; includeSubdomains", w.Header().Get("Strict-Transport-Security")) } +func TestStsHeaderWithSubdomainAndPreload(t *testing.T) { + router := newServer(Config{ + STSSeconds: 315360000, + STSIncludeSubdomains: true, + STSPreload: true, + }) + + w := performRequest(router, "/foo") + + assert.Equal(t, http.StatusOK, w.Code) + assert.Equal(t, "max-age=315360000; includeSubdomains; preload", w.Header().Get("Strict-Transport-Security")) +} + func TestFrameDeny(t *testing.T) { router := newServer(Config{ FrameDeny: true,