Use url.Parse to parse hostname (#12335)
This commit is contained in:
parent
7ecb25b41b
commit
e6c9f19b8f
1 changed files with 2 additions and 5 deletions
|
@ -626,11 +626,8 @@ func NewContext() {
|
||||||
StaticURLPrefix = strings.TrimSuffix(sec.Key("STATIC_URL_PREFIX").MustString(AppSubURL), "/")
|
StaticURLPrefix = strings.TrimSuffix(sec.Key("STATIC_URL_PREFIX").MustString(AppSubURL), "/")
|
||||||
AppSubURLDepth = strings.Count(AppSubURL, "/")
|
AppSubURLDepth = strings.Count(AppSubURL, "/")
|
||||||
// Check if Domain differs from AppURL domain than update it to AppURL's domain
|
// Check if Domain differs from AppURL domain than update it to AppURL's domain
|
||||||
urlHostname, _, err := net.SplitHostPort(appURL.Host)
|
urlHostname := appURL.Hostname()
|
||||||
if err != nil {
|
if urlHostname != Domain && net.ParseIP(urlHostname) == nil && urlHostname != "" {
|
||||||
log.Fatal("Invalid host in ROOT_URL '%s': %s", appURL.Host, err)
|
|
||||||
}
|
|
||||||
if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
|
|
||||||
Domain = urlHostname
|
Domain = urlHostname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue