// ResolveUrl returns an absolute URL for a possibly relative URL.
548617
func (bow *Browser) ResolveUrl(u *url.URL) *url.URL {
	return bow.Url().ResolveReference(u)
}
179207
func (b *XMLBase) ResolveURL(u string) (string, error) {
	if b.CurrentBase() == "" {
		return u, nil
	}

	relURL, err := url.Parse(u)
	if err != nil {
		return u, err
	}
	curr := b.CurrentBaseURL()
	if curr.Path != "" && u != "" && curr.Path[len(curr.Path)-1] != '/' {
		// There's no reason someone would use a path in xml:base if they
		// didn't mean for it to be a directory
		curr.Path = curr.Path + "/"
	}
	absURL := b.CurrentBaseURL().ResolveReference(relURL)
	return absURL.String(), nil
}
235302
func (s *Schema) ResolveURL(v string) (u *url.URL, err error) {
	if pdebug.Enabled {
		g := pdebug.IPrintf("START Schema.ResolveURL '%s'", v)
		defer func() {
			if err != nil {
				g.IRelease("END Schema.ResolveURL '%s': error %s", v, err)
			} else {
				g.IRelease("END Schema.ResolveURL '%s' -> '%s'", v, u)
			}
		}()
	}
	base := s.BaseURL()
	if pdebug.Enabled {
		pdebug.Printf("Using base URL '%s'", base)
	}
	u, err = base.Parse(v)
	if err != nil {
		return nil, err
	}
	return u, nil
}
575874
func URL(u *url.URL) RequestOption {
	return func(req *http.Request) (*http.Request, error) {
		req.URL = u
		return req, nil
	}
}
1163793
func ResolveURLFromServer(srv *http.Server) string {
	scheme := ResolveSchemeFromServer(srv)
	host := ResolveVHost(srv.Addr)
	return scheme + "://" + host
}
819769
function resolveUrl(url){
    
    // replace all // except the one in proto with /
    url = url.replace(reDoubleSlash, "$1/");
    
    // If the url is a valid url we do nothing
    if (!url.match(/^(http||https):\/\//)) {
        // If this is a relative path
        var path = (url.substring(0, 1) === "/") ? "" : location.pathname;
        if (path.substring(path.length - 1) !== "/") {
            path = path.substring(0, path.lastIndexOf("/") + 1);
        }
        
        url = location.protocol + "//" + location.host + path + url;
    }
    
    // reduce all 'xyz/../' to just '' 
    while (reParent.test(url)) {
        url = url.replace(reParent, "");
    }
    
    return url;
}
930823
func AbsoluteURLAsURL(req *http.Request, relative string) (*url.URL, error) {
	return url.Parse(AbsoluteURL(req, relative))
}
510625
func (h *urlDataSource) URL(path string) (string, error) {
	return utils.MakeFileURL(urlJoin(h.baseURL, path)), nil
}
486833
func (a *AdminEnforcement) GetURL() string {
	if a == nil || a.URL == nil {
		return ""
	}
	return *a.URL
}
1262556
func (internet Internet) URL(v reflect.Value) (interface{}, error) {
	return internet.url(), nil
}
1178088
func resolveBundleURL(store URLResolver, maybeBundle string) (*charm.URL, params.Channel, error) {
	userRequestedURL, err := charm.ParseURL(maybeBundle)
	if err != nil {
		return nil, "", errors.Trace(err)
	}

	// Charm or bundle has been supplied as a URL so we resolve and
	// deploy using the store.
	storeCharmOrBundleURL, channel, _, err := resolveCharm(store.ResolveWithChannel, userRequestedURL)
	if err != nil {
		return nil, "", errors.Trace(err)
	}
	if storeCharmOrBundleURL.Series != "bundle" {
		logger.Debugf(
			`cannot interpret as charmstore bundle: %v (series) != "bundle"`,
			storeCharmOrBundleURL.Series,
		)
		return nil, "", errors.NotValidf("charmstore bundle %q", maybeBundle)
	}
	return storeCharmOrBundleURL, channel, nil
}
1107819
func ResolveURL(scheme string, addr string) string {
	host := ResolveVHost(addr)
	return scheme + "://" + host
}
1130383
func PatchURL(originalURL string, params ...interface{}) (patchedURL string, err error) {
	url, err := url.Parse(originalURL)
	if err != nil {
		return
	}

	query := url.Query()
	for i := 0; i < len(params)/2; i++ {
		// Check if params is key&value pair
		key := fmt.Sprintf("%v", params[i*2])
		value := fmt.Sprintf("%v", params[i*2+1])

		if value == "" {
			query.Del(key)
		} else {
			query.Set(key, value)
		}
	}

	url.RawQuery = query.Encode()
	patchedURL = url.String()
	return
}
1043434
func (r *Request) URL() *URL {
	return NewURL(r.TLS != nil, r.Host+r.RequestURI)
}
655602
func (r *Resolver) ResolveN(domain string, depth int) (link string, err error) {
	tail := ""
	for i := 0; i < depth; i++ {
		link, err = r.resolveOnce(domain)
		if err != nil {
			return "", err
		}

		// if does not have /dns/ as a prefix, done.
		if !strings.HasPrefix(link, "/dns/") {
			return link + tail, nil // done
		}

		// keep resolving
		d, rest, err := ParseLinkDomain(link)
		if err != nil {
			return "", err
		}

		domain = d
		tail = rest + tail
	}
	return "/dns/" + domain + tail, ErrResolveLimit
}
592793
func cleanURL(url *string) {
	ulen := len((*url))
	if ulen > 1 {
		if (*url)[ulen-1:] == "/" {
			*url = (*url)[:ulen-1]
			cleanURL(url)
		}
	}
}
976091
func ResolveHome(path string) string {
	if path[:2] == "~/" {
		usr, _ := user.Current()
		dir := usr.HomeDir
		path = strings.Replace(path, "~/", dir, 1)
	}

	return path
}