// ParseHostURL parses a url string, validates the string is a host url, and
// returns the parsed URL
ParseHostURL parses a url string, validates the string is a host url, and
returns the parsed URL
// ParseHostURL parses a url string validates the string is a host url and // returns the parsed URL
func ParseHostURL(host string) (*url.URL, error) {
	protoAddrParts := strings.SplitN(host, "://", 2)
	if len(protoAddrParts) == 1 {
		return nil, fmt.Errorf("unable to parse docker host `%s`", host)
	}
	var basePath string
	proto, addr := protoAddrParts[0], protoAddrParts[1]
	if proto == "tcp" {
		parsed, err := url.Parse("tcp://" + addr)
		if err != nil {
			return nil, err
		}
		addr = parsed.Host
		basePath = parsed.Path
	}
	return &url.URL{
		Scheme: proto,
		Host:   addr,
		Path:   basePath,
	}, nil
}
func ParseHostURL ( host string ) ( * url . URL , error ) { protoAddrParts := strings . SplitN ( host , " " , 2 ) if len ( protoAddrParts ) == 1 { return nil , fmt . Errorf ( " " , host ) } var basePath string proto , addr := protoAddrParts [ 0 ] , protoAddrParts [ 1 ] if proto == " " { parsed , err := url . Parse ( " " + addr ) if err != nil { return nil , err } addr = parsed . Host basePath = parsed . Path } return & url . URL { Scheme : proto , Host : addr , Path : basePath , } , nil }
ParseHostURL parses a url string, validates the string is a host url, and
returns the parsed URL
ParseHostURL parses a url string validates the string is a host url and returns the parsed URL