mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-23 06:18:59 +00:00
16 lines
418 B
Go
16 lines
418 B
Go
package server
|
|
|
|
import (
|
|
"bytes"
|
|
)
|
|
|
|
// GetHSTSHeader returns a HSTS header with includeSubdomains & preload for MainDomainSuffix and RawDomain, or an empty
|
|
// string for custom domains.
|
|
func GetHSTSHeader(host, mainDomainSuffix, rawDomain []byte) string {
|
|
if bytes.HasSuffix(host, mainDomainSuffix) || bytes.Equal(host, rawDomain) {
|
|
return "max-age=63072000; includeSubdomains; preload"
|
|
} else {
|
|
return ""
|
|
}
|
|
}
|