// ParseURL attempts to parse a URL contained within a MessageEntity.
426108
func (e MessageEntity) ParseURL() (*url.URL, error) {
	if e.URL == "" {
		return nil, errors.New(ErrBadURL)
	}

	return url.Parse(e.URL)
}
828424
func normalizeURL(dest string) (string, error) {
	u, err := url.Parse(dest)
	if err != nil {
		return "", err
	}
	// Note: '//host/path' is a location on a server named 'host'.
	if u.IsAbs() || !strings.HasPrefix(u.Path, "/") || strings.HasPrefix(u.Path, "//") {
		return "", errBadDestinationURL
	}
	// path.Clean removes trailing slash. It matters for URLs though. Keep it.
	keepSlash := strings.HasSuffix(u.Path, "/")
	u.Path = path.Clean(u.Path)
	if !strings.HasSuffix(u.Path, "/") && keepSlash {
		u.Path += "/"
	}
	if !strings.HasPrefix(u.Path, "/") {
		return "", errBadDestinationURL
	}
	return u.String(), nil
}
254505
func parseMetaURL(mu string, tls bool) (metaURL *url.URL, err error) {
	if strings.Contains(mu, "http") {
		metaURL, err = url.Parse(mu)
	} else {
		metaURL = &url.URL{
			Scheme: "http",
			Host:   mu,
		}
	}

	if tls {
		metaURL.Scheme = "https"
	}

	return
}
1332422
func (i *Issue) GetURL() string {
	if i == nil || i.URL == nil {
		return ""
	}
	return *i.URL
}
879852
func validateURL(ctx *validation.Context, s string) (*url.URL, bool) {
	// url.Parse considers "example.com/a/b" to be a path, so ensure a scheme.
	if !strings.HasPrefix(s, "https://") {
		s = "https://" + s
	}
	u, err := url.Parse(s)
	if err != nil {
		ctx.Error(errors.Annotate(err, "not a valid URL").Err())
		return nil, false
	}
	valid := true
	if !strings.HasSuffix(u.Host, ".googlesource.com") {
		ctx.Errorf("isn't at *.googlesource.com %q", u.Host)
		valid = false
	}
	if u.Scheme != "" && u.Scheme != "https" {
		ctx.Errorf("scheme must be https")
		valid = false
	}
	if strings.HasSuffix(u.Host, "-review.googlesource.com") {
		ctx.Errorf("must not be a Gerrit host (try without '-review')")
		valid = false
	}
	return u, valid
}
1120063
func (r *RepositoryRelease) GetURL() string {
	if r == nil || r.URL == nil {
		return ""
	}
	return *r.URL
}
588417
func parseRepoURL(image string) (*parsedURL, error) {
	parsed, err := url.Parse("https://" + image)
	if err != nil {
		return nil, fmt.Errorf("error parsing image %s %v", image, err)
	}
	splitURL := ecrPattern.FindStringSubmatch(parsed.Hostname())
	if len(splitURL) == 0 {
		return nil, fmt.Errorf("%s is not a valid ECR repository URL", parsed.Hostname())
	}
	return &parsedURL{
		registryID: splitURL[1],
		region:     splitURL[3],
		registry:   parsed.Hostname(),
	}, nil
}
1060177
func ParseURL(redisURL string) (*Options, error) {
	o := &Options{Network: "tcp"}
	u, err := url.Parse(redisURL)
	if err != nil {
		return nil, err
	}

	if u.Scheme != "redis" && u.Scheme != "rediss" {
		return nil, errors.New("invalid redis URL scheme: " + u.Scheme)
	}

	if u.User != nil {
		if p, ok := u.User.Password(); ok {
			o.Password = p
		}
	}

	if len(u.Query()) > 0 {
		return nil, errors.New("no options supported")
	}

	h, p, err := net.SplitHostPort(u.Host)
	if err != nil {
		h = u.Host
	}
	if h == "" {
		h = "localhost"
	}
	if p == "" {
		p = "6379"
	}
	o.Addr = net.JoinHostPort(h, p)

	f := strings.FieldsFunc(u.Path, func(r rune) bool {
		return r == '/'
	})
	switch len(f) {
	case 0:
		o.DB = 0
	case 1:
		if o.DB, err = strconv.Atoi(f[0]); err != nil {
			return nil, fmt.Errorf("invalid redis database number: %q", f[0])
		}
	default:
		return nil, errors.New("invalid redis URL path: " + u.Path)
	}

	if u.Scheme == "rediss" {
		o.TLSConfig = &tls.Config{ServerName: h}
	}
	return o, nil
}
605654
func (s *Server) URL() (u *url.URL, err error) {
	if s.Scheme == "" {
		return u, fmt.Errorf("Server %s:%d has no scheme, cannot make a URL", s.Host, s.Port)
	}

	ustring := fmt.Sprintf("%s://%s:%d", s.Scheme, s.Host, s.Port)

	u, err = url.Parse(ustring)
	if err != nil {
		return u, fmt.Errorf("Could not parse %s: %s", ustring, err)
	}

	return
}
15231
func ParseSHAFromURL(url string) (string, error) {
	r, err := http.Get(url)
	if err != nil {
		return "", errors.Wrap(err, "Error downloading checksum.")
	} else if r.StatusCode != http.StatusOK {
		return "", errors.Errorf("Error downloading checksum. Got HTTP Error: %s", r.Status)
	}

	defer r.Body.Close()
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return "", errors.Wrap(err, "Error reading checksum.")
	}

	return strings.Trim(string(body), "\n"), nil
}
116972
func (client *Client) GetUrl(entity string, project string, id string) string {
	var url = client.GetApiUri()
	url += GetRequestPath(entity, project, id)
	//	var pageStr = "",
	//	  filterStr = "";
	//	if (filter) {
	//	  for (var kk in filter) {
	//	    filterStr += "&" + kk + "=" + filter[kk];
	//	  }
	//	}
	//	if (pagination) {
	//	  pageStr = "&page=" + (Math.floor(pagination.index / pagination.size) + 1) + "&pageSize=" + pagination.size;
	//	}
	//	if (filterStr || pageStr) {
	//	  url += "?resource" + filterStr + pageStr;
	//	}
	//	return url;

	return url
}
513532
func parseURL(urlString string) (*url.URL, error) {
	url, parseErr := url.Parse(urlString)
	if parseErr != nil {
		return nil, parseErr
	}
	if url == nil {
		return nil, fmt.Errorf("No URL")
	}
	return url, nil
}
1352314
func (c *CommitsComparison) GetURL() string {
	if c == nil || c.URL == nil {
		return ""
	}
	return *c.URL
}
124422
func (p *PullRequestLinks) GetURL() string {
	if p == nil || p.URL == nil {
		return ""
	}
	return *p.URL
}
477205
func (r *Reactions) GetURL() string {
	if r == nil || r.URL == nil {
		return ""
	}
	return *r.URL
}
396524
func ParseURL(urlStr string) (result *url.URL, err error) {
	result, err = url.Parse(urlStr)
	if result != nil && result.Scheme == "" {
		result = nil
		err = fmt.Errorf("invalid URL <%s>", urlStr)
	}
	return
}
717632
func fixURL(u *url.URL) *url.URL {
	if u.Scheme == "" {
		s := strings.Split(u.String(), "/")
		u.Scheme = "http"
		u.Host = s[0]
		u.Path = u.Path[len(s[0]):]
	}
	return u
}