pages-server/server/handler/hsts.go

16 lines
429 B
Go
Raw Normal View History

2022-11-12 18:44:04 +01:00
package handler
import (
2022-08-28 16:21:37 +02:00
"strings"
)
2022-11-07 23:01:31 +01:00
// getHSTSHeader returns a HSTS header with includeSubdomains & preload for MainDomainSuffix and RawDomain, or an empty
// string for custom domains.
2022-11-07 23:01:31 +01:00
func getHSTSHeader(host, mainDomainSuffix, rawDomain string) string {
2022-08-28 16:21:37 +02:00
if strings.HasSuffix(host, mainDomainSuffix) || strings.EqualFold(host, rawDomain) {
return "max-age=63072000; includeSubdomains; preload"
} else {
return ""
}
}