// From https://golang.org/src/net/url/url.go
436050
func ishex(c rune) bool {
	switch {
	case '0' <= c && c <= '9':
		return true
	case 'a' <= c && c <= 'f':
		return true
	case 'A' <= c && c <= 'F':
		return true
	}
	return false
}
1101977
func RawURL(request *http.Request) string {
	return strings.Join([]string{request.URL.Scheme, "://", request.URL.Host, request.RequestURI}, "")
}
417041
func (r *Request) PathUrl(p string) (*url.URL, error) {
	return url.Parse(r.BaseURL + path.Join("/", p))
}
44704
func URL(c CloneURL, path string) *Resource {
	r := &Resource{u: c.URL()}
	r.u.Path = Path + path
	return r
}
1076453
func (c *conn) URL() string {
	c.RLock()
	defer c.RUnlock()
	return c.url
}
613556
func (i *item) URL() *url.URL {
	str, err := i.bucket.FileURL(i.name)
	if err != nil {
		return nil
	}

	url, _ := url.Parse(str)
	url.Scheme = Kind

	return url
}
1175239
func (r *route) URLWith(args []string) string {
	if len(args) > 0 {
		argCount := len(args)
		i := 0
		url := urlReg.ReplaceAllStringFunc(r.pattern, func(m string) string {
			var val interface{}
			if i < argCount {
				val = args[i]
			} else {
				val = m
			}
			i += 1
			return fmt.Sprintf(`%v`, val)
		})

		return url
	}
	return r.pattern
}
712611
func (b *Bucket) URL(path string) string {
	req := &request{
		bucket: b.Name,
		path:   path,
	}
	err := b.KS3.prepare(req)
	if err != nil {
		panic(err)
	}
	u, err := req.url()
	if err != nil {
		panic(err)
	}
	u.RawQuery = ""
	return u.String()
}
1009083
func formatURL(scheme string, host string, port int, path string) *url.URL {
	u, err := url.Parse(path)
	// Something is busted with the path, but it's too late to reject it. Pass it along as is.
	if err != nil {
		u = &url.URL{
			Path: path,
		}
	}
	u.Scheme = scheme
	u.Host = net.JoinHostPort(host, strconv.Itoa(port))
	return u
}
1316338
func (e IntervalActionInfo) Url() string {
	url := fmt.Sprintf("%s://%s:%v", e.Protocol, e.Host, e.Port)
	return url
}
1101654
func (hrt HTMLRichText) URL(text string, url string) string {
	text = fmt.Sprintf("<a href=\"%s\">%s</a>", url, hrt.EncodeEntities(text))
	return text
}
631403
func (c *Clair) url(pathTemplate string, args ...interface{}) string {
	pathSuffix := fmt.Sprintf(pathTemplate, args...)
	url := fmt.Sprintf("%s%s", c.URL, pathSuffix)
	return url
}
400672
func (r *Request) URL(uri string) *Request {
	r.Use(url.URL(uri))
	return r
}
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
}
995646
func (b *Builder) URL(httpAttemptCount int, urls ...*url.URL) *Builder {
	for _, u := range urls {
		b.paths = append(b.paths, &URLVisitor{
			URL:              u,
			StreamVisitor:    NewStreamVisitor(nil, b.mapper, u.String(), b.schema),
			HttpAttemptCount: httpAttemptCount,
		})
	}
	return b
}
334881
func (p *parserMixin) URL() (target **url.URL) {
	target = new(*url.URL)
	p.URLVar(target)
	return
}
874823
func FromURL(URL string) (OTP, string, error) {
	u, err := url.Parse(URL)
	if err != nil {
		return nil, "", err
	}

	if u.Scheme != "otpauth" {
		return nil, "", ErrInvalidURL
	}

	switch {
	case u.Host == "totp":
		return totpFromURL(u)
	case u.Host == "hotp":
		return hotpFromURL(u)
	default:
		return nil, "", ErrInvalidURL
	}
}