Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions secure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down