// parsePath parses the Registry URL path (after <scheme>://<host>:<port>)
// into namespace, repo, and tag. All of these are optional parts of the
// path.
540403
func (url *DockerRegistryURL) parsePath(s string) error {
	s, err := cleanPath(s)
	if err != nil {
		return err
	}

	if s == "" {
		return nil
	}

	imageName, tag, err := parseTag(s)
	if err != nil {
		return err
	}
	url.Tag = tag
	url.ImageName = imageName

	return nil
}
112563
func ParseURL(s string) (u *URL, err error) {
	var uu *url.URL
	if uu, err = url.Parse(s); err != nil {
		return nil, err
	}

	if uu.Host == "" {
		if uu.Scheme != "" {
			return nil, errors.New("scheme appears with empty host")
		}
	} else if _, err = ParseHost(uu.Host); err != nil {
		return nil, err
	}

	// Clean path in the URL.
	// Note: path.Clean() is used on purpose because in MS Windows filepath.Clean() converts
	// `/` into `\` ie `/foo` becomes `\foo`
	if uu.Path != "" {
		uu.Path = path.Clean(uu.Path)
	}

	v := URL(*uu)
	u = &v
	return u, nil
}
982147
func (r *Request) Path(path string) *Request {
	r.Use(url.Path(path))
	return r
}
1307551
func (e *Entry) Path() string {
	if e.Parent == nil {
		return ""
	}

	var p []string

	for e != nil && e.Parent != nil {
		p = append(p, e.Name)
		e = e.Parent
	}

	l := len(p) / 2
	for i := 0; i < l; i++ {
		j := len(p) - i - 1
		p[i], p[j] = p[j], p[i]
	}

	return strings.Join(p, "/")
}
796720
func (r *route) Path(path string) types.Route {
	r.path = path
	return r
}
914727
func ParseURL(daemonURL string) (*Spec, error) {
	u, err := url.Parse(daemonURL)
	if err != nil {
		return nil, err
	}
	if u.Scheme != "ssh" {
		return nil, errors.Errorf("expected scheme ssh, got %q", u.Scheme)
	}

	var sp Spec

	if u.User != nil {
		sp.User = u.User.Username()
		if _, ok := u.User.Password(); ok {
			return nil, errors.New("plain-text password is not supported")
		}
	}
	sp.Host = u.Hostname()
	if sp.Host == "" {
		return nil, errors.Errorf("no host specified")
	}
	sp.Port = u.Port()
	if u.Path != "" {
		return nil, errors.Errorf("extra path after the host: %q", u.Path)
	}
	if u.RawQuery != "" {
		return nil, errors.Errorf("extra query after the host: %q", u.RawQuery)
	}
	if u.Fragment != "" {
		return nil, errors.Errorf("extra fragment after the host: %q", u.Fragment)
	}
	return &sp, err
}
1051377
func (s *Service) path() string {
	return fmt.Sprintf("%s/%s:%d", RegistryPath, s.Name, s.Port)
}
305765
func (_m *RouterGroup) Path() string {
	ret := _m.Called()

	var r0 string
	if rf, ok := ret.Get(0).(func() string); ok {
		r0 = rf()
	} else {
		r0 = ret.Get(0).(string)
	}

	return r0
}
258341
func XMLPath(t T, r *http.Response, xpath string) interface{} {
	if r == nil {
		logfatal(t, sfatalf("XMLPath: no response to read body from"))
		return nil
	}
	if r.Body == nil {
		logfatal(t, sfatalf("XMLPath: no response body to read"))
		return nil
	}
	path, err := xmlpath.Compile(xpath)
	if err != nil {
		logerror(t, serrorf("XMLPath: invalid xpath expression:%v", err))
		return nil
	}
	data, err := ioutil.ReadAll(r.Body)
	if err != nil {
		logerror(t, serrorf("XMLPath: unable to read response body"))
		return nil
	}
	root, err := xmlpath.Parse(bytes.NewReader(data))
	// put the body back for re-reads
	r.Body = ioutil.NopCloser(bytes.NewReader(data))

	if err != nil {
		logerror(t, serrorf("XMLPath: unable to parse xml:%v", err))
		return nil
	}
	if value, ok := path.String(root); ok {
		return value
	}
	logerror(t, serrorf("XMLPath: no value for path: %s", xpath))
	return nil
}
640531
func GetRegistryPath(browser string) (string, error) {
	path, found := registryPaths[browser]
	if !found {
		return "", fmt.Errorf("browser %s on %s is currently not supported", browser, runtime.GOOS)
	}
	return path, nil
}
980241
func apiPath(modelTag names.ModelTag, path string) (string, error) {
	if !strings.HasPrefix(path, "/") {
		return "", errors.Errorf("cannot make API path from non-slash-prefixed path %q", path)
	}
	modelUUID := modelTag.Id()
	if modelUUID == "" {
		return path, nil
	}
	return modelRoot + modelUUID + path, nil
}
1306124
func (p *parser) parsePath(data bool) *ast.PathExpression {
	var tok *lexer.Token

	// ID
	tok = p.shift()
	if tok.Kind != lexer.TokenID {
		errExpected(lexer.TokenID, tok)
	}

	result := ast.NewPathExpression(tok.Pos, tok.Line, data)
	result.Part(tok.Val)

	for p.isPathSep() {
		// SEP
		tok = p.shift()
		result.Sep(tok.Val)

		// ID
		tok = p.shift()
		if tok.Kind != lexer.TokenID {
			errExpected(lexer.TokenID, tok)
		}

		result.Part(tok.Val)

		if len(result.Parts) > 0 {
			switch tok.Val {
			case "..", ".", "this":
				errToken(tok, "Invalid path: "+result.Original)
			}
		}
	}

	return result
}
1131078
func Path(baseDir string, name string) string {
	key := repoKeyStr(name)
	return filepath.Join(baseDir, key)
}
426108
func (e MessageEntity) ParseURL() (*url.URL, error) {
	if e.URL == "" {
		return nil, errors.New(ErrBadURL)
	}

	return url.Parse(e.URL)
}
443329
func (u *DockerRegistryURL) Path() string {
	if u.Tag == "" {
		return u.ImageName
	} else {
		return fmt.Sprintf("%s:%s", u.ImageName, u.Tag)
	}
}
129985
func (f *FileName) Path() string {
	cp := strings.Split(f.Name, "\x00")

	if len(cp) == 0 || cp[0] != serverPolicyRootShareName {
		return "" // TODO: not happening until if/when we handle Windows shares
	}

	cp[0] = ""

	return strings.Join(cp, "/")
}
1082101
func parseS3Path(path string) (string, string, error) {
	// S3 path names are of the form s3://bucket/key
	stringsArray := strings.SplitN(path, "/", 4)
	if len(stringsArray) < 4 {
		return "", "", fmt.Errorf("Invalid s3 path %s", path)
	}
	bucketName := stringsArray[2]
	// Everything after the third slash is the key
	key := stringsArray[3]
	return bucketName, key, nil
}