// ValidateRepoURL validates gitiles repository URL.
553256
func ValidateRepoURL(repoURL string) error {
	_, _, err := ParseRepoURL(repoURL)
	return err
}
238425
func ValidateURL(value string) error {
	if _, err := url.Parse(value); err != nil {
		return err
	}
	return nil
}
969374
func ValidateURIs(uris ...string) Validatable {
	return func() error {
		for i := range uris {
			uri := uris[i]
			if len(uri) < 7 {
				return errors.Wrapf(ErrInvalidURI, "%s at index %d", uris[i], i)
			}
			schema := uri[:6]
			if schema != "tcp://" && schema != "udp://" {
				return errors.Wrapf(ErrInvalidURI, "%s at index %d", uris[i], i)
			}
			if _, err := url.Parse(uri[6:]); err != nil {
				return errors.Wrapf(ErrInvalidURI, "%s at index %d", uris[i], i)
			}
		}
		return nil
	}
}
1314650
func (r *RepositoryLicense) GetGitURL() string {
	if r == nil || r.GitURL == nil {
		return ""
	}
	return *r.GitURL
}
23112
func ValidateIsURL(value interface{}) error {
	if u, err := url.Parse(typeutil.String(value)); err == nil {
		if u.Scheme == `` || u.Host == `` || u.Path == `` {
			return fmt.Errorf("Invalid URL")
		}
	} else {
		return err
	}

	return nil
}
520854
func validateRule(ctx *validation.Context, title string, r *admin.ServiceAccountRule) {
	ctx.Enter(title)
	defer ctx.Exit()

	if r.Name == "" {
		ctx.Errorf(`"name" is required`)
	}

	// Note: we allow any of the sets to be empty. The rule will just not match
	// anything in this case, this is fine.
	validateEmails(ctx, "service_account", r.ServiceAccount)
	validateGroups(ctx, "service_account_group", r.ServiceAccountGroup)
	validateScopes(ctx, "allowed_scope", r.AllowedScope)
	validateIDSet(ctx, "end_user", r.EndUser)
	validateIDSet(ctx, "proxy", r.Proxy)
	validateIDSet(ctx, "trusted_proxy", r.TrustedProxy)
	validateMaxGrantValidityDuration(ctx, r.MaxGrantValidityDuration)
}
810290
func (r *Repository) GetReleasesURL() string {
	if r == nil || r.ReleasesURL == nil {
		return ""
	}
	return *r.ReleasesURL
}
1231936
func (c *Content) IsRepoValidURL() bool {
	r, err := regexp.Compile(`(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$`)
	if err != nil {
		return false
	}
	return r.MatchString(c.Repository)
}
134951
func ValidateURLs(urls []string, requireHTTPS bool, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}
	for _, urlstr := range urls {
		u, err := url.Parse(urlstr)
		if err != nil {
			allErrs = append(allErrs, field.Invalid(fldPath, urlstr, fmt.Sprintf("URL parse error: %v", err)))
			continue
		}
		if requireHTTPS && u.Scheme != "https" {
			allErrs = append(allErrs, field.Invalid(fldPath, urlstr, "the URL must be using the HTTPS scheme"))
		}
		if u.Scheme == "" {
			allErrs = append(allErrs, field.Invalid(fldPath, urlstr, "the URL without scheme is not allowed"))
		}
	}
	return allErrs
}
151725
func (r *Repository) GetGitURL() string {
	if r == nil || r.GitURL == nil {
		return ""
	}
	return *r.GitURL
}
1239654
func (r *RepositoryRelease) GetTarballURL() string {
	if r == nil || r.TarballURL == nil {
		return ""
	}
	return *r.TarballURL
}
1287500
func ParseURL(sURL string) (*Options, error) {
	parsedURL, err := url.Parse(sURL)
	if err != nil {
		return nil, err
	}

	// scheme
	if parsedURL.Scheme != "postgres" && parsedURL.Scheme != "postgresql" {
		return nil, errors.New("pg: invalid scheme: " + parsedURL.Scheme)
	}

	// host and port
	options := &Options{
		Addr: parsedURL.Host,
	}
	if !strings.Contains(options.Addr, ":") {
		options.Addr += ":5432"
	}

	// username and password
	if parsedURL.User != nil {
		options.User = parsedURL.User.Username()

		if password, ok := parsedURL.User.Password(); ok {
			options.Password = password
		}
	}

	if options.User == "" {
		options.User = "postgres"
	}

	// database
	if len(strings.Trim(parsedURL.Path, "/")) > 0 {
		options.Database = parsedURL.Path[1:]
	} else {
		return nil, errors.New("pg: database name not provided")
	}

	// ssl mode
	query, err := url.ParseQuery(parsedURL.RawQuery)
	if err != nil {
		return nil, err
	}

	if sslMode, ok := query["sslmode"]; ok && len(sslMode) > 0 {
		switch sslMode[0] {
		case "allow", "prefer", "require":
			options.TLSConfig = &tls.Config{InsecureSkipVerify: true} //nolint
		case "disable":
			options.TLSConfig = nil
		default:
			return nil, fmt.Errorf("pg: sslmode '%v' is not supported", sslMode[0])
		}
	} else {
		options.TLSConfig = &tls.Config{InsecureSkipVerify: true} //nolint
	}

	delete(query, "sslmode")

	if appName, ok := query["application_name"]; ok && len(appName) > 0 {
		options.ApplicationName = appName[0]
	}

	delete(query, "application_name")

	if len(query) > 0 {
		return nil, errors.New("pg: options other than 'sslmode' and 'application_name' are not supported")
	}

	return options, nil
}
521563
func (w *repoWalker) subURL(relURL string) (*url.URL, error) {
	if w.repoURL == nil {
		return nil, fmt.Errorf("no URL for base repo")
	}
	if strings.HasPrefix(relURL, "../") {
		u := *w.repoURL
		u.Path = path.Join(u.Path, relURL)
		return &u, nil
	}

	return url.Parse(relURL)
}
642611
func (r *Repository) GetCompareURL() string {
	if r == nil || r.CompareURL == nil {
		return ""
	}
	return *r.CompareURL
}
15863
func ValidateUriList(baseUriList string, redirectUri string, separator string) (realRedirectUri string, err error) {
	// make a list of uris
	var slist []string
	if separator != "" {
		slist = strings.Split(baseUriList, separator)
	} else {
		slist = make([]string, 0)
		slist = append(slist, baseUriList)
	}

	for _, sitem := range slist {
		realRedirectUri, err = ValidateUri(sitem, redirectUri)
		// validated, return no error
		if err == nil {
			return realRedirectUri, nil
		}

		// if there was an error that is not a validation error, return it
		if _, iok := err.(UriValidationError); !iok {
			return "", err
		}
	}

	return "", newUriValidationError("urls don't validate", baseUriList, redirectUri)
}
1262274
func (i *Import) GetRepositoryURL() string {
	if i == nil || i.RepositoryURL == nil {
		return ""
	}
	return *i.RepositoryURL
}
341247
func (s *Subscription) GetRepositoryURL() string {
	if s == nil || s.RepositoryURL == nil {
		return ""
	}
	return *s.RepositoryURL
}