Create an absolute url from a relative one.

        >>> url_formatter = URLFormatter("example.com", 80)
        >>> url_formatter.get_abs_url("kml_master.kml")
        'http://example.com:80/kml_master.kml'
543283
def get_abs_url(self, rel_url):
        
        rel_url = rel_url.lstrip("/")
        return "{}://{}:{}/{}".format(self.url_scheme, self.host, self.port, rel_url)
482210
def makeCNBaseURL(url):
    """"""
    o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_CN_PROTOCOL)
    if o.netloc and o.path:
        netloc = o.netloc
        path = o.path
    elif o.netloc:
        netloc = o.netloc
        path = d1_common.const.DEFAULT_CN_PATH
    elif o.path:
        s = o.path.split('/', 1)
        netloc = s[0]
        if len(s) == 1:
            path = d1_common.const.DEFAULT_CN_PATH
        else:
            path = s[1]
    else:
        netloc = d1_common.const.DEFAULT_CN_HOST
        path = d1_common.const.DEFAULT_CN_PATH
    return urllib.parse.urlunparse(
        (o.scheme, netloc, path, o.params, o.query, o.fragment)
    )
1078451
def download_url(self, url, **kwargs):
        
        if self.baseurl and '://' not in url:
            url = join(self.baseurl, url)
        return self.resolver.download_to_directory(self.directory, url, **kwargs)
387269
def relative(self):
        
        if not self.is_absolute():
            raise ValueError("URL should be absolute")
        val = self._val._replace(scheme="", netloc="")
        return URL(val, encoded=True)
957119
def get_absolute_url(self):
        
        if not self.tree_parent_id:
            url = reverse('root_homepage')
        else:
            url = reverse('category_detail', kwargs={'category' : self.tree_path})
        if self.site_id != settings.SITE_ID:
            # prepend the domain if it doesn't match current Site
            return 'http://' + self.site.domain + url
        return url
731728
def absolute_urls(html):
    

    from bs4 import BeautifulSoup
    from yacms.core.request import current_request

    request = current_request()
    if request is not None:
        dom = BeautifulSoup(html, "html.parser")
        for tag, attr in ABSOLUTE_URL_TAGS.items():
            for node in dom.findAll(tag):
                url = node.get(attr, "")
                if url:
                    node[attr] = request.build_absolute_uri(url)
        html = str(dom)
    return html
234779
public final URL toURL(String relativeUrl) {
    try {
      URL url = toURL();
      return new URL(url, relativeUrl);
    } catch (MalformedURLException e) {
      throw new IllegalArgumentException(e);
    }
  }
49131
def url_map(self, for_user=None, **kwargs):
        
        class Home:
            title = _("Home")
        home = Home()
        setattr(home, "get_absolute_url", home_slug)
        items = {home.get_absolute_url(): home}
        for model in apps.get_models():
            if issubclass(model, self.model):
                for item in (model.objects.published(for_user=for_user)
                                  .filter(**kwargs)
                                  .exclude(slug__startswith="http://")
                                  .exclude(slug__startswith="https://")):
                    items[item.get_absolute_url()] = item
        return items
535898
def build_url(base_url, path):
    
    if absolute_http_url_regexp.match(path):
        return path
    elif base_url:
        return "{}/{}".format(base_url.rstrip("/"), path.lstrip("/"))
    else:
        raise ParamsError("base url missed!")
217596
public static function abs_url($url, $base)
    {
        if (!self::is_url_path($url)) {
            $t = is_array($base) ? $base : parse_url($base);
            if (strncmp($url, '//', 2) == 0) {
                if (!empty($t['scheme'])) {
                    $url = $t['scheme'] . ':' . $url;
                }
            } else {
                $base = (empty($t['scheme']) ? '//' : $t['scheme'] . '://') .
                    $t['host'] . (empty($t['port']) ? '' : ':' . $t['port']);
                if (!empty($t['path'])) {
                    $s = dirname($t['path'] . 'f');
                    if (DIRECTORY_SEPARATOR != '/') {
                        $s = strtr($s, DIRECTORY_SEPARATOR, '/');
                    }
                    if ($s && '.' !== $s && '/' !== $s && substr($url, 0, 1) !== '/') {
                        $base .= '/' . ltrim($s, '/');
                    }
                }
                $url = rtrim($base, '/') . '/' . ltrim($url, '/');
            }
        } else {
            $p = strpos($url, ':');
            if (substr($url, $p + 3, 1) === '/' && in_array(substr($url, 0, $p), array('http', 'https'))) {
                $url = substr($url, 0, $p + 3) . ltrim(substr($url, $p + 3), '/');
            }
        }
        return $url;
    }
239020
private static function InternetCombineUrl( $absolute, $relative )
	{
		if ( $relative == "" ) return $absolute;

		$p = parse_url( $relative );

		if( isset( $p["scheme"] ) ) return $relative;

		extract( parse_url( $absolute ) );

		$path = dirname( $path );
		if ( $path = "\\" ) $path = "/";

		if ( $relative[0] == '/' )
		{
			$cparts = array_filter( explode( "/", $relative ) );
		}
		else
		{
			$aparts = array_filter(explode( "/", $path ) );
			$rparts = array_filter(explode( "/", $relative ) );
			$cparts = array_merge( $aparts, $rparts );
			foreach( $cparts as $i => $part )
			{
				if( $part == '.')
				{
					$cparts[$i] = null;
				}

				if($part == '..')
				{
					$cparts[$i - 1] = null;
					$cparts[$i] = null;
				}
			}
			$cparts = array_filter( $cparts );
		}

		$path = implode( "/", $cparts );
		$url = "";
		if ( $scheme )
		{
			$url = "$scheme://";
		}
		if ( isset( $user ) )
		{
			$url .= "$user";
			if( $pass )
			{
				$url .= ":$pass";
			}
			$url .= "@";
		}

		if( $host )
		{
			$url .= "$host/";
		}

		$url .= $path;

		return $url;
	}
1021444
def URL(base, path, segments=None, defaults=None):
    
    # Make a copy of the Segments class
    url_class = type(Segments.__name__, Segments.__bases__,
                     dict(Segments.__dict__))
    segments = [] if segments is None else segments
    defaults = [] if defaults is None else defaults
    # For each segment attach a property capable of getting and setting it
    for segment in segments:
        setattr(url_class, segment, url_class._segment(segment))
    # Instantiate the class with the actual parameters
    return url_class(base, path, segments, defaults)
107843
public static String constructAbsoluteUrl(String theBase, String theEndpoint) {
		if (theEndpoint == null) {
			return null;
		}
		if (isAbsolute(theEndpoint)) {
			return theEndpoint;
		}
		if (theBase == null) {
			return theEndpoint;
		}

		try {
			return new URL(new URL(theBase), theEndpoint).toString();
		} catch (MalformedURLException e) {
			ourLog.warn("Failed to resolve relative URL[" + theEndpoint + "] against absolute base[" + theBase + "]", e);
			return theEndpoint;
		}
	}
518207
def base_url(klass, space_id, resource_id=None, public=False, environment_id=None, **kwargs):
        

        if public:
            environment_slug = ""
            if environment_id is not None:
                environment_slug = "/environments/{0}".format(environment_id)
            return "spaces/{0}{1}/public/content_types".format(space_id, environment_slug)
        return super(ContentType, klass).base_url(
            space_id,
            resource_id=resource_id,
            environment_id=environment_id,
            **kwargs
        )
881079
def static_url(path, absolute=False):
    

    if os.sep != '/':
        path = '/'.join(path.split(os.sep))

    return flask.url_for('static', filename=path, _external=absolute)
329036
def make_absolute(base, relative):
        

        # Python 3.4 and lower do not remove folder traversal strings.
        # This was fixed in 3.5 (https://docs.python.org/3/whatsnew/3.5.html#urllib)
        while relative.startswith('/../') or relative.startswith('../'):
            relative = relative[3:]

            base_parsed = urlparse(base)
            new_path = base_parsed.path.rsplit('/', 1)[0]
            base_parsed = base_parsed._replace(path=new_path)
            base = base_parsed.geturl()

        return urljoin(base, relative)
318339
def get_absolute_url_link(self, text=None, cls=None, icon_class=None,
                              **attrs):
        """"""
        if text is None:
            text = self.get_link_text()

        return build_link(href=self.get_absolute_url(),
                          text=text,
                          cls=cls,
                          icon_class=icon_class,
                          **attrs)