|
@@ -282,13 +282,12 @@ func (cli *Client) HTTPClient() *http.Client {
|
|
// ParseHostURL parses a url string, validates the string is a host url, and
|
|
// ParseHostURL parses a url string, validates the string is a host url, and
|
|
// returns the parsed URL
|
|
// returns the parsed URL
|
|
func ParseHostURL(host string) (*url.URL, error) {
|
|
func ParseHostURL(host string) (*url.URL, error) {
|
|
- protoAddrParts := strings.SplitN(host, "://", 2)
|
|
|
|
- if len(protoAddrParts) == 1 {
|
|
|
|
|
|
+ proto, addr, ok := strings.Cut(host, "://")
|
|
|
|
+ if !ok || addr == "" {
|
|
return nil, errors.Errorf("unable to parse docker host `%s`", host)
|
|
return nil, errors.Errorf("unable to parse docker host `%s`", host)
|
|
}
|
|
}
|
|
|
|
|
|
var basePath string
|
|
var basePath string
|
|
- proto, addr := protoAddrParts[0], protoAddrParts[1]
|
|
|
|
if proto == "tcp" {
|
|
if proto == "tcp" {
|
|
parsed, err := url.Parse("tcp://" + addr)
|
|
parsed, err := url.Parse("tcp://" + addr)
|
|
if err != nil {
|
|
if err != nil {
|