mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-24 22:06:57 +00:00
refactor
This commit is contained in:
parent
0742782a0d
commit
8d0ab6d8c0
1 changed files with 7 additions and 9 deletions
|
@ -8,10 +8,6 @@ import (
|
||||||
|
|
||||||
// CheckCanonicalDomain returns the canonical domain specified in the repo (using the `.domains` file).
|
// CheckCanonicalDomain returns the canonical domain specified in the repo (using the `.domains` file).
|
||||||
func CheckCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, mainDomainSuffix, giteaRoot, giteaAPIToken string, canonicalDomainCache cache.SetGetKey) (string, bool) {
|
func CheckCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, mainDomainSuffix, giteaRoot, giteaAPIToken string, canonicalDomainCache cache.SetGetKey) (string, bool) {
|
||||||
return checkCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, mainDomainSuffix, giteaRoot, giteaAPIToken, canonicalDomainCache)
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, mainDomainSuffix, giteaRoot, giteaAPIToken string, canonicalDomainCache cache.SetGetKey) (string, bool) {
|
|
||||||
var (
|
var (
|
||||||
domains []string
|
domains []string
|
||||||
valid bool
|
valid bool
|
||||||
|
@ -25,13 +21,15 @@ func checkCanonicalDomain(targetOwner, targetRepo, targetBranch, actualDomain, m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
body, err := giteaRawContent(giteaRoot, targetRepo, targetBranch, giteaRoot, giteaAPIToken, canonicalDomainConfig)
|
body, err := giteaRawContent(targetOwner, targetRepo, targetBranch, giteaRoot, giteaAPIToken, canonicalDomainConfig)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, domain := range strings.Split(string(body), "\n") {
|
for _, domain := range strings.Split(string(body), "\n") {
|
||||||
domain = strings.ToLower(domain)
|
domain = strings.TrimPrefix(
|
||||||
domain = strings.TrimSpace(domain)
|
strings.TrimPrefix(
|
||||||
domain = strings.TrimPrefix(domain, "http://")
|
strings.TrimSpace(
|
||||||
domain = strings.TrimPrefix(domain, "https://")
|
strings.ToLower(domain)),
|
||||||
|
"http://"),
|
||||||
|
"https://")
|
||||||
if len(domain) > 0 && !strings.HasPrefix(domain, "#") && !strings.ContainsAny(domain, "\t /") && strings.ContainsRune(domain, '.') {
|
if len(domain) > 0 && !strings.HasPrefix(domain, "#") && !strings.ContainsAny(domain, "\t /") && strings.ContainsRune(domain, '.') {
|
||||||
domains = append(domains, domain)
|
domains = append(domains, domain)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue