func ParseURL(url string) (*URL, error) {
	// Check if we're dealing with a v1 or v2 URL.
	u, err := gourl.Parse(url)
	if err != nil {
		return nil, errors.Errorf("cannot parse charm or bundle URL: %q", url)
	}
	if u.RawQuery != "" || u.Fragment != "" || u.User != nil {
		return nil, errors.Errorf("charm or bundle URL %q has unrecognized parts", url)
	}
	var curl *URL
	switch {
	case CharmHub.Matches(u.Scheme):
		// Handle talking to the new style of the schema.
		curl, err = parseIdentifierURL(u)
	case u.Opaque != "":
		u.Path = u.Opaque
		curl, err = parseV1URL(u, url)
	case CharmStore.Matches(u.Scheme):
		curl, err = parseV1URL(u, url)
	case HTTP.Matches(u.Scheme) || HTTPS.Matches(u.Scheme):
		curl, err = parseHTTPURL(u)
	default:
		// Handle the fact that anything without a prefix is now a CharmHub
		// charm URL.
		curl, err = parseIdentifierURL(u)
	}
	if err != nil {
		return nil, errors.Trace(err)
	}
	if curl.Schema == "" {
		return nil, errors.Errorf("expected schema for charm or bundle URL: %q", url)
	}
	return curl, nil
}
// ParseURL parses the provided charm URL string into its respective
// structure.
//
// Additionally, fully-qualified charmstore URLs are supported; note that this
// currently assumes that they will map to jujucharms.com (that is,
// fully-qualified URLs currently map to the 'cs' schema):
//
//    https://jujucharms.com/name
//    https://jujucharms.com/name/series
//    https://jujucharms.com/name/revision
//    https://jujucharms.com/name/series/revision
//    https://jujucharms.com/u/user/name
//    https://jujucharms.com/u/user/name/series
//    https://jujucharms.com/u/user/name/revision
//    https://jujucharms.com/u/user/name/series/revision
//
// A missing schema is assumed to be 'cs'.
ParseURL parses the provided charm URL string into its respective
structure.

Additionally, fully-qualified charmstore URLs are supported; note that this
currently assumes that they will map to jujucharms.com (that is,
fully-qualified URLs currently map to the 'cs' schema).



A missing schema is assumed to be 'cs'.
// ParseURL parses the provided charm URL string into its respective // structure . // // Additionally fully - qualified charmstore URLs are supported ; note that this // currently assumes that they will map to jujucharms . com ( that is // fully - qualified URLs currently map to the ' cs ' schema ) : // // https : // jujucharms . com / name // https : // jujucharms . com / name / series // https : // jujucharms . com / name / revision // https : // jujucharms . com / name / series / revision // https : // jujucharms . com / u / user / name // https : // jujucharms . com / u / user / name / series // https : // jujucharms . com / u / user / name / revision // https : // jujucharms . com / u / user / name / series / revision // // A missing schema is assumed to be ' cs ' .
func ParseURL(url string) (*URL, error) {
	u, err := gourl.Parse(url)
	if err != nil {
		return nil, errors.Errorf("cannot parse charm or bundle URL: %q", url)
	}
	if u.RawQuery != "" || u.Fragment != "" || u.User != nil {
		return nil, errors.Errorf("charm or bundle URL %q has unrecognized parts", url)
	}
	var curl *URL
	switch {
	case CharmHub.Matches(u.Scheme):
		curl, err = parseIdentifierURL(u)
	case u.Opaque != "":
		u.Path = u.Opaque
		curl, err = parseV1URL(u, url)
	case CharmStore.Matches(u.Scheme):
		curl, err = parseV1URL(u, url)
	case HTTP.Matches(u.Scheme) || HTTPS.Matches(u.Scheme):
		curl, err = parseHTTPURL(u)
	default:
		curl, err = parseIdentifierURL(u)
	}
	if err != nil {
		return nil, errors.Trace(err)
	}
	if curl.Schema == "" {
		return nil, errors.Errorf("expected schema for charm or bundle URL: %q", url)
	}
	return curl, nil
}
func ParseURL ( url string ) ( * URL , error ) { u , err := gourl . Parse ( url ) if err != nil { return nil , errors . Errorf ( " " , url ) } if u . RawQuery != " " || u . Fragment != " " || u . User != nil { return nil , errors . Errorf ( " " , url ) } var curl * URL switch { case CharmHub . Matches ( u . Scheme ) : curl , err = parseIdentifierURL ( u ) case u . Opaque != " " : u . Path = u . Opaque curl , err = parseV1URL ( u , url ) case CharmStore . Matches ( u . Scheme ) : curl , err = parseV1URL ( u , url ) case HTTP . Matches ( u . Scheme ) || HTTPS . Matches ( u . Scheme ) : curl , err = parseHTTPURL ( u ) default : curl , err = parseIdentifierURL ( u ) } if err != nil { return nil , errors . Trace ( err ) } if curl . Schema == " " { return nil , errors . Errorf ( " " , url ) } return curl , nil }
ParseURL parses the provided charm URL string into its respective
structure.
ParseURL parses the provided charm URL string into its respective structure .
// Check if we're dealing with a v1 or v2 URL. // Handle talking to the new style of the schema. // Handle the fact that anything without a prefix is now a CharmHub // charm URL.