This commit is contained in:
6543 2022-11-07 23:01:31 +01:00
parent a03ea956d5
commit 218b52094e
No known key found for this signature in database
GPG Key ID: B8BE6D610E61C862
3 changed files with 5 additions and 4 deletions

View File

@ -46,7 +46,7 @@ func Handler(mainDomainSuffix, rawDomain string,
trimmedHost := utils.TrimHostPort(req.Host)
// Add HSTS for RawDomain and MainDomainSuffix
if hsts := GetHSTSHeader(trimmedHost, mainDomainSuffix, rawDomain); hsts != "" {
if hsts := getHSTSHeader(trimmedHost, mainDomainSuffix, rawDomain); hsts != "" {
ctx.RespWriter.Header().Set("Strict-Transport-Security", hsts)
}
@ -92,6 +92,7 @@ func Handler(mainDomainSuffix, rawDomain string,
// tryBranch checks if a branch exists and populates the target variables. If canonicalLink is non-empty, it will
// also disallow search indexing and add a Link header to the canonical URL.
// TODO: move into external func to not alert vars indirectly
tryBranch := func(log zerolog.Logger, repo, branch string, _path []string, canonicalLink string) bool {
if repo == "" {
log.Debug().Msg("tryBranch: repo == ''")

View File

@ -4,9 +4,9 @@ import (
"strings"
)
// GetHSTSHeader returns a HSTS header with includeSubdomains & preload for MainDomainSuffix and RawDomain, or an empty
// getHSTSHeader returns a HSTS header with includeSubdomains & preload for MainDomainSuffix and RawDomain, or an empty
// string for custom domains.
func GetHSTSHeader(host, mainDomainSuffix, rawDomain string) string {
func getHSTSHeader(host, mainDomainSuffix, rawDomain string) string {
if strings.HasSuffix(host, mainDomainSuffix) || strings.EqualFold(host, rawDomain) {
return "max-age=63072000; includeSubdomains; preload"
} else {

View File

@ -18,7 +18,7 @@ func GetBranchTimestamp(giteaClient *gitea.Client, owner, repo, branch string) *
log.Err(err).Msg("Could't fetch default branch from repository")
return nil
}
log.Debug().Msgf("found default branch: %s", defaultBranch)
log.Debug().Msgf("Succesfully fetched default branch '%s' from Gitea", defaultBranch)
branch = defaultBranch
}