From 4565481643dfd9014a674cd5a182a6c42e820fe0 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 12 Nov 2022 21:16:11 +0100 Subject: [PATCH] refactor: finish use default const for defaultPagesBranch and defaultPagesRepo --- server/handler/handler.go | 2 ++ server/handler/handler_sub_domain.go | 3 --- server/handler/try.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/handler/handler.go b/server/handler/handler.go index b42751e..1a0a285 100644 --- a/server/handler/handler.go +++ b/server/handler/handler.go @@ -16,6 +16,8 @@ import ( const ( headerAccessControlAllowOrigin = "Access-Control-Allow-Origin" headerAccessControlAllowMethods = "Access-Control-Allow-Methods" + defaultPagesRepo = "pages" + defaultPagesBranch = "pages" ) // Handler handles a single HTTP request to the web server. diff --git a/server/handler/handler_sub_domain.go b/server/handler/handler_sub_domain.go index 59d1bbc..73177b6 100644 --- a/server/handler/handler_sub_domain.go +++ b/server/handler/handler_sub_domain.go @@ -15,9 +15,6 @@ import ( "codeberg.org/codeberg/pages/server/upstream" ) -const defaultPagesRepo = "pages" -const defaultPagesBranch = "pages" - func handleSubDomain(log zerolog.Logger, ctx *context.Context, giteaClient *gitea.Client, mainDomainSuffix string, trimmedHost string, diff --git a/server/handler/try.go b/server/handler/try.go index b9adb7b..bae3c44 100644 --- a/server/handler/try.go +++ b/server/handler/try.go @@ -24,7 +24,7 @@ func tryUpstream(ctx *context.Context, giteaClient *gitea.Client, canonicalDomain, _ := options.CheckCanonicalDomain(giteaClient, "", string(mainDomainSuffix), canonicalDomainCache) if !strings.HasSuffix(strings.SplitN(canonicalDomain, "/", 2)[0], string(mainDomainSuffix)) { canonicalPath := ctx.Req.RequestURI - if options.TargetRepo != "pages" { + if options.TargetRepo != defaultPagesRepo { path := strings.SplitN(canonicalPath, "/", 3) if len(path) >= 3 { canonicalPath = "/" + path[2]