From c1fbe861fe793eb335cab63a524e5ae2bb3fb7f1 Mon Sep 17 00:00:00 2001 From: crapStone Date: Sun, 11 Feb 2024 12:43:25 +0000 Subject: [PATCH] rename gitea to forge in html error messages (#287) closes #286 Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/287 Reviewed-by: Andreas Shimokawa Co-authored-by: crapStone Co-committed-by: crapStone --- server/certificates/certificates.go | 2 +- server/handler/try.go | 2 +- server/upstream/domains.go | 2 +- server/upstream/upstream.go | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/certificates/certificates.go b/server/certificates/certificates.go index 3ae891a..4fb99fa 100644 --- a/server/certificates/certificates.go +++ b/server/certificates/certificates.go @@ -199,7 +199,7 @@ func (c *AcmeClient) retrieveCertFromDB(sni, mainDomainSuffix string, useDnsProv func (c *AcmeClient) obtainCert(acmeClient *lego.Client, domains []string, renew *certificate.Resource, user string, useDnsProvider bool, mainDomainSuffix string, keyDatabase database.CertDB) (*tls.Certificate, error) { name := strings.TrimPrefix(domains[0], "*") - if useDnsProvider && len(domains[0]) > 0 && domains[0][0] == '*' { + if useDnsProvider && domains[0] != "" && domains[0][0] == '*' { domains = domains[1:] } diff --git a/server/handler/try.go b/server/handler/try.go index 838ae27..bb79dce 100644 --- a/server/handler/try.go +++ b/server/handler/try.go @@ -41,7 +41,7 @@ func tryUpstream(ctx *context.Context, giteaClient *gitea.Client, // Try to request the file from the Gitea API if !options.Upstream(ctx, giteaClient, redirectsCache) { - html.ReturnErrorPage(ctx, "gitea client failed", ctx.StatusCode) + html.ReturnErrorPage(ctx, "forge client failed", ctx.StatusCode) } } diff --git a/server/upstream/domains.go b/server/upstream/domains.go index eb30394..230f268 100644 --- a/server/upstream/domains.go +++ b/server/upstream/domains.go @@ -41,7 +41,7 @@ func (o *Options) CheckCanonicalDomain(giteaClient *gitea.Client, actualDomain, domain = strings.TrimSpace(domain) domain = strings.TrimPrefix(domain, "http://") domain = strings.TrimPrefix(domain, "https://") - if len(domain) > 0 && !strings.HasPrefix(domain, "#") && !strings.ContainsAny(domain, "\t /") && strings.ContainsRune(domain, '.') { + if domain != "" && !strings.HasPrefix(domain, "#") && !strings.ContainsAny(domain, "\t /") && strings.ContainsRune(domain, '.') { domains = append(domains, domain) } if domain == actualDomain { diff --git a/server/upstream/upstream.go b/server/upstream/upstream.go index 1a444e4..4a85503 100644 --- a/server/upstream/upstream.go +++ b/server/upstream/upstream.go @@ -57,7 +57,7 @@ func (o *Options) Upstream(ctx *context.Context, giteaClient *gitea.Client, redi log := log.With().Strs("upstream", []string{o.TargetOwner, o.TargetRepo, o.TargetBranch, o.TargetPath}).Logger() if o.TargetOwner == "" || o.TargetRepo == "" { - html.ReturnErrorPage(ctx, "gitea client: either repo owner or name info is missing", http.StatusBadRequest) + html.ReturnErrorPage(ctx, "forge client: either repo owner or name info is missing", http.StatusBadRequest) return true } @@ -153,16 +153,16 @@ func (o *Options) Upstream(ctx *context.Context, giteaClient *gitea.Client, redi var msg string if err != nil { - msg = "gitea client: returned unexpected error" + msg = "forge client: returned unexpected error" log.Error().Err(err).Msg(msg) msg = fmt.Sprintf("%s: '%v'", msg, err) } if reader == nil { - msg = "gitea client: returned no reader" + msg = "forge client: returned no reader" log.Error().Msg(msg) } if statusCode != http.StatusOK { - msg = fmt.Sprintf("gitea client: couldn't fetch contents: %d - %s", statusCode, http.StatusText(statusCode)) + msg = fmt.Sprintf("forge client: couldn't fetch contents: %d - %s", statusCode, http.StatusText(statusCode)) log.Error().Msg(msg) }