1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-29 20:53:10 +00:00

Use url.Parse to parse hostname (#12335)

This commit is contained in:
techknowlogick 2020-07-26 20:16:22 -04:00 committed by GitHub
parent 7ecb25b41b
commit e6c9f19b8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -626,11 +626,8 @@ func NewContext() {
StaticURLPrefix = strings.TrimSuffix(sec.Key("STATIC_URL_PREFIX").MustString(AppSubURL), "/")
AppSubURLDepth = strings.Count(AppSubURL, "/")
// Check if Domain differs from AppURL domain than update it to AppURL's domain
urlHostname, _, err := net.SplitHostPort(appURL.Host)
if err != nil {
log.Fatal("Invalid host in ROOT_URL '%s': %s", appURL.Host, err)
}
if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
urlHostname := appURL.Hostname()
if urlHostname != Domain && net.ParseIP(urlHostname) == nil && urlHostname != "" {
Domain = urlHostname
}