internal/home: Add a status page on home
This commit is contained in:
parent
7cda92b342
commit
3d4db1744b
9 changed files with 301 additions and 118 deletions
|
|
@ -42,18 +42,26 @@ func (cfg Config) DefaultSSLHost() string {
|
|||
return cfg.IfHttps(cfg.DefaultHost())
|
||||
}
|
||||
|
||||
// SlugFromHost returns the slug belonging to the appropriate host.
|
||||
func (cfg Config) SlugFromHost(host string) (slug string) {
|
||||
// SlugFromHost returns the slug belonging to the appropriate host.'
|
||||
//
|
||||
// When host is a top-level domain, returns "", true.
|
||||
// When no slug is found, returns "", false.
|
||||
func (cfg Config) SlugFromHost(host string) (slug string, ok bool) {
|
||||
// extract an ':port' that happens to be in the host.
|
||||
domain, _, _ := strings.Cut(host, ":")
|
||||
domainL := strings.ToLower(domain)
|
||||
|
||||
// check all the possible domain endings
|
||||
for _, suffix := range append([]string{cfg.DefaultDomain}, cfg.SelfExtraDomains...) {
|
||||
if strings.HasSuffix(domain, "."+suffix) {
|
||||
return domain[:len(domain)-len(suffix)-1]
|
||||
suffixL := strings.ToLower(suffix)
|
||||
if domainL == suffixL {
|
||||
return "", true
|
||||
}
|
||||
if strings.HasSuffix(domainL, "."+suffixL) {
|
||||
return domain[:len(domain)-len(suffix)-1], true
|
||||
}
|
||||
}
|
||||
|
||||
// no domain found!
|
||||
return ""
|
||||
return "", ok
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue