2022-11-12 19:43:44 +00:00
|
|
|
package handler
|
2021-11-20 14:30:58 +00:00
|
|
|
|
2021-12-01 21:49:48 +00:00
|
|
|
import (
|
2022-11-12 19:37:20 +00:00
|
|
|
"strings"
|
2021-12-01 21:49:48 +00:00
|
|
|
)
|
2021-11-20 14:30:58 +00:00
|
|
|
|
2022-11-12 19:37:20 +00:00
|
|
|
// getHSTSHeader returns a HSTS header with includeSubdomains & preload for MainDomainSuffix and RawDomain, or an empty
|
2021-11-20 14:30:58 +00:00
|
|
|
// string for custom domains.
|
2022-11-12 19:37:20 +00:00
|
|
|
func getHSTSHeader(host, mainDomainSuffix, rawDomain string) string {
|
|
|
|
if strings.HasSuffix(host, mainDomainSuffix) || strings.EqualFold(host, rawDomain) {
|
2021-11-20 14:30:58 +00:00
|
|
|
return "max-age=63072000; includeSubdomains; preload"
|
|
|
|
} else {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|