(key string)
| 9 | ) |
| 10 | |
| 11 | func ParseHost(key string) string { |
| 12 | var schemeIndex = strings.Index(key, "://") |
| 13 | if schemeIndex <= 0 { |
| 14 | return "" |
| 15 | } |
| 16 | |
| 17 | var firstSlashIndex = strings.Index(key[schemeIndex+3:], "/") |
| 18 | if firstSlashIndex <= 0 { |
| 19 | return "" |
| 20 | } |
| 21 | |
| 22 | var host = key[schemeIndex+3 : schemeIndex+3+firstSlashIndex] |
| 23 | |
| 24 | hostPart, _, err := net.SplitHostPort(host) |
| 25 | if err == nil && len(hostPart) > 0 { |
| 26 | host = configutils.QuoteIP(hostPart) |
| 27 | } |
| 28 | |
| 29 | return host |
| 30 | } |
no outgoing calls