[std-http] fix-header (#134)

Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/134
This commit is contained in:
6543 2022-11-11 06:38:09 +01:00
parent 4117775cf0
commit 7526873049
9 changed files with 72 additions and 75 deletions

View file

@ -80,7 +80,7 @@ func Handler(mainDomainSuffix, rawDomain string,
ctx.RespWriter.Header().Set("Allow", http.MethodGet+", "+http.MethodHead+", "+http.MethodOptions) // duplic 1
if ctx.IsMethod(http.MethodOptions) {
ctx.Response().StatusCode = http.StatusNoContent
ctx.RespWriter.WriteHeader(http.StatusNoContent)
return
}
@ -119,8 +119,8 @@ func Handler(mainDomainSuffix, rawDomain string,
if canonicalLink != "" {
// Hide from search machines & add canonical link
ctx.Response().Header.Set("X-Robots-Tag", "noarchive, noindex")
ctx.Response().Header.Set("Link",
ctx.RespWriter.Header().Set("X-Robots-Tag", "noarchive, noindex")
ctx.RespWriter.Header().Set("Link",
strings.NewReplacer("%b", targetBranch, "%p", targetPath).Replace(canonicalLink)+
"; rel=\"canonical\"",
)