func NewRepoURI(s string) (repo *RepoURI, err error) {
	// trim off the scheme and make sure that it validates
	scheme, rest := utils.SplitBefore(s, "://")
	if scheme != "" && !validateScheme(scheme) {
		rest = scheme + "://" + rest
	}

	// trim off authentication
	auth, rest := utils.SplitBefore(rest, "@")
	user, password := utils.SplitAfter(auth, ":")

	// if we have a ':', we need to determine if it is a port or a path
	var hostname, path, sport string
	var port int
	if strings.ContainsRune(rest, ':') {
		// trim off the hostname
		hostname, path = utils.SplitBefore(rest, ":")

		// if we have a scheme, then we have to parse everything after ':' as a port
		if scheme != "" {
			sport, path = utils.SplitAfter(path, "/")
			if port, err = parsePort(sport); err != nil {
				path = sport + "/" + path
				port = 0
				err = nil
			}
		}

	} else {
		// the first part of the url is a hostname
		hostname, path = utils.SplitAfter(rest, "/")
	}

	repo = &RepoURI{scheme, user, password, hostname, port, path}

	return
}
// NewRepoURI parses a new repo uri from a string
NewRepoURI parses a new repo uri from a string
// NewRepoURI parses a new repo uri from a string
func NewRepoURI(s string) (repo *RepoURI, err error) {
	scheme, rest := utils.SplitBefore(s, "://")
	if scheme != "" && !validateScheme(scheme) {
		rest = scheme + "://" + rest
	}
	auth, rest := utils.SplitBefore(rest, "@")
	user, password := utils.SplitAfter(auth, ":")
	var hostname, path, sport string
	var port int
	if strings.ContainsRune(rest, ':') {
		hostname, path = utils.SplitBefore(rest, ":")
		if scheme != "" {
			sport, path = utils.SplitAfter(path, "/")
			if port, err = parsePort(sport); err != nil {
				path = sport + "/" + path
				port = 0
				err = nil
			}
		}
	} else {
		hostname, path = utils.SplitAfter(rest, "/")
	}
	repo = &RepoURI{scheme, user, password, hostname, port, path}
	return
}
func NewRepoURI ( s string ) ( repo * RepoURI , err error ) { scheme , rest := utils . SplitBefore ( s , " " ) if scheme != " " && ! validateScheme ( scheme ) { rest = scheme + " " + rest } auth , rest := utils . SplitBefore ( rest , " " ) user , password := utils . SplitAfter ( auth , " " ) var hostname , path , sport string var port int if strings . ContainsRune ( rest , ':' ) { hostname , path = utils . SplitBefore ( rest , " " ) if scheme != " " { sport , path = utils . SplitAfter ( path , " " ) if port , err = parsePort ( sport ) ; err != nil { path = sport + " " + path port = 0 err = nil } } } else { hostname , path = utils . SplitAfter ( rest , " " ) } repo = & RepoURI { scheme , user , password , hostname , port , path } return }
NewRepoURI parses a new repo uri from a string
NewRepoURI parses a new repo uri from a string
// trim off the scheme and make sure that it validates // trim off authentication // if we have a ':', we need to determine if it is a port or a path // trim off the hostname // if we have a scheme, then we have to parse everything after ':' as a port // the first part of the url is a hostname