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]