aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authortechknowlogick <techknowlogick@gitea.io>2020-07-26 20:16:22 -0400
committerGitHub <noreply@github.com>2020-07-26 20:16:22 -0400
commite6c9f19b8f712c01456cafb2225950825dcc1ce9 (patch)
tree6e84d3844292b9d56d6e90bad6b6ee1ae57a04cd /modules/setting
parent7ecb25b41b4ae174c101ab0e55f5b930d7ffc597 (diff)
downloadgitea-e6c9f19b8f712c01456cafb2225950825dcc1ce9.tar.gz
gitea-e6c9f19b8f712c01456cafb2225950825dcc1ce9.zip
Use url.Parse to parse hostname (#12335)
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/setting.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 199f27a21f..f98addb3cd 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -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
}