config.go: add http prefix to ORIGIN and CDN_PREFIX
This commit is contained in:
parent
89a81ece19
commit
3205766248
@ -63,12 +63,14 @@ func configParse() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
os.Setenv("ORIGIN", strings.TrimSuffix(os.Getenv("ORIGIN"), "/"))
|
os.Setenv("ORIGIN", strings.TrimSuffix(os.Getenv("ORIGIN"), "/"))
|
||||||
|
os.Setenv("ORIGIN", addHttpIfAbsent(os.Getenv("ORIGIN")))
|
||||||
|
|
||||||
if os.Getenv("CDN_PREFIX") == "" {
|
if os.Getenv("CDN_PREFIX") == "" {
|
||||||
os.Setenv("CDN_PREFIX", os.Getenv("ORIGIN"))
|
os.Setenv("CDN_PREFIX", os.Getenv("ORIGIN"))
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Setenv("CDN_PREFIX", strings.TrimSuffix(os.Getenv("ORIGIN"), "/"))
|
os.Setenv("CDN_PREFIX", strings.TrimSuffix(os.Getenv("ORIGIN"), "/"))
|
||||||
|
os.Setenv("CDN_PREFIX", addHttpIfAbsent(os.Getenv("CDN_PREFIX")))
|
||||||
|
|
||||||
if os.Getenv("FORBID_NEW_OWNERS") != "true" && os.Getenv("FORBID_NEW_OWNERS") != "false" {
|
if os.Getenv("FORBID_NEW_OWNERS") != "true" && os.Getenv("FORBID_NEW_OWNERS") != "false" {
|
||||||
logger.Errorf("COMMENTO_FORBID_NEW_OWNERS neither 'true' nor 'false'")
|
logger.Errorf("COMMENTO_FORBID_NEW_OWNERS neither 'true' nor 'false'")
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var prePlusMatch = regexp.MustCompile(`([^@\+]*)\+?(.*)@.*`)
|
var prePlusMatch = regexp.MustCompile(`([^@\+]*)\+?(.*)@.*`)
|
||||||
@ -43,3 +44,11 @@ func isHttpsUrl(in string) bool {
|
|||||||
// solves this. If this function returns false, prefix with "http://"
|
// solves this. If this function returns false, prefix with "http://"
|
||||||
return len(httpsUrl.FindAllString(in, -1)) != 0
|
return len(httpsUrl.FindAllString(in, -1)) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addHttpIfAbsent(in string) string {
|
||||||
|
if !strings.HasPrefix(in, "http://") && !strings.HasPrefix(in, "https://") {
|
||||||
|
return "http://" + in
|
||||||
|
}
|
||||||
|
|
||||||
|
return in
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user