diff --git a/config/url_config.go b/config/url_config.go index a8e9bcce..d8fe1b34 100644 --- a/config/url_config.go +++ b/config/url_config.go @@ -35,11 +35,7 @@ func (c *URLConfig) get(key, rawurl string) (string, bool) { return "", false } - hosts := make([]string, 0) - if u.User != nil { - hosts = append(hosts, fmt.Sprintf("%s://%s@%s", u.Scheme, u.User.Username(), u.Host)) - } - hosts = append(hosts, fmt.Sprintf("%s://%s", u.Scheme, u.Host)) + hosts := c.hosts(u) pLen := len(u.Path) if pLen > 2 { @@ -73,3 +69,14 @@ func (c *URLConfig) get(key, rawurl string) (string, bool) { return "", false } + +func (c *URLConfig) hosts(u *url.URL) []string { + hosts := make([]string, 0, 1) + + if u.User != nil { + hosts = append(hosts, fmt.Sprintf("%s://%s@%s", u.Scheme, u.User.Username(), u.Host)) + } + hosts = append(hosts, fmt.Sprintf("%s://%s", u.Scheme, u.Host)) + + return hosts +}