Resolve url - among other things will turn relative url to absolute

@method resolveUrl
@static
@param {String} url Either absolute or relative
@return {String} Resolved, absolute url
8689
function(url) {
		var ports = { // we ignore default ports
			http: 80,
			https: 443
		}
		, urlp = parseUrl(url)
		;

		return urlp.scheme + '://' + urlp.host + (urlp.port !== ports[urlp.scheme] ? ':' + urlp.port : '') + urlp.path + (urlp.query ? urlp.query : '');
	}
616654
function getUrl (url) {
  var opt = {
    url: url
  , timeout: 10000 // 10 seconds
  }
  ;
  return new Promise(function(resolve, reject){
    request(opt, function(err, res, body){
      if (err) { return reject(err); }
      resolve(body)
    });
  });
}
935939
function repairUrl(url) {
	return normalizeUrl(url
		.replace(/&amp;/gi, '&')
		.replace(/&lt;/gi, '<')
		.replace(/&gt;/gi, '>')
		.replace(/&quot;/gi, '"')
		.replace(/&#039;/gi, '\'')
	)
		.trim()
		.replace(/\s+/g,'+')
}
1328911
public function resolve($url)
    {
        $baseUrl = Utils::sanitizeUri($this->getBasePath());
        $baseDir = pathinfo($baseUrl, PATHINFO_DIRNAME);

        if (empty($baseDir)) {
            $msg = "The base directory of the document ('${baseDir}') could not be resolved.";
            throw new ResolutionException($msg);
        }

        $href = $baseDir . '/' . ltrim($url, '/');

        return $href;
    }
844663
function(baseUrl, url) {
  if (!resolveCache) {
    var iframe = document.createElement('iframe');
    document.documentElement.appendChild(iframe);
    var doc = iframe.contentWindow.document;
    var base = doc.createElement('base');
    doc.documentElement.appendChild(base);
    var a = doc.createElement('a');
    doc.documentElement.appendChild(a);
    iframe.parentNode.removeChild(iframe);
    resolveCache = {
      iframe: iframe,
      base: base,
      a: a
    };
  }
  resolveCache.base.href = baseUrl;
  resolveCache.a.href = url;
  return resolveCache.a.href;
}
19714
public static function resolve(Url $url)
    {
        foreach (self::$patterns as $method => $pattern) {
            if ($url->match($pattern)) {
                return self::$method($url);
            }
        }

        return $url;
    }
793810
function (url) {
                if (!url)
                    return "";

                var urlParts = url.split("/"),
                    newPath = "";

                for (var i = 0, len = urlParts.length; i < len; i++) {
                    var part = urlParts[i];

                    if (!part || part.length === 0
                        || part.indexOf(":") != -1
                        || part === "."
                        || part === ".."
                        || part === "null"
                        || part === "undefined") {
                        continue;
                    }

                    if (newPath.length !== 0) {
                        newPath = newPath + "/";
                    }

                    newPath = newPath + part;
                }

                return newPath;
            }
210139
function resolve (from, to) {

    if (isRemoteFile(from)) {

        if (!/\/$/.test(from)) {
            from += '/';
        }

        return url.resolve(from, to);
    } else if (isRemoteFile(to)) {
        return to;
    } else {
        return path.resolve(from, to);
    }
}
249931
public static String getCanonicalURL(String url, String baseURL) {

		try {
			/* Build the absolute URL, from the url and the baseURL */
			String resolvedURL = URLResolver.resolveUrl(baseURL == null ? "" : baseURL, url);
			log.debug("Resolved URL: " + resolvedURL);
			URI canonicalURI;
			try {
				canonicalURI = new URI(resolvedURL);
			} catch (Exception e) {
				canonicalURI = new URI(URIUtil.encodeQuery(resolvedURL));
			}

			/* Some checking. */
			if (canonicalURI.getScheme() == null) {
				log.warn("Protocol could not be reliably evaluated from uri: " + canonicalURI + " and base url: " + baseURL);
				return null;
			}

			if (canonicalURI.getRawAuthority() == null) {
				log.debug("Ignoring URI with no authority (host[\":\"port]): " + canonicalURI + " (on base " + baseURL + ")");
				return null;
			}

			if (canonicalURI.getHost() == null) {
				log.warn("Host could not be reliably evaluated from: " + canonicalURI + " (on base " + baseURL + ")");
				return null;
			}

			/*
			 * Normalize: no empty segments (i.e., "//"), no segments equal to ".", and no segments equal to
			 * ".." that are preceded by a segment not equal to "..".
			 */
			String path = canonicalURI.normalize().getRawPath();

			/* Convert '//' -> '/' */
			int idx = path.indexOf("//");
			while (idx >= 0) {
				path = path.replace("//", "/");
				idx = path.indexOf("//");
			}

			/* Drop starting '/../' */
			while (path.startsWith("/../")) {
				path = path.substring(3);
			}

			/* Trim */
			path = path.trim();

			/* Process parameters and sort them. */
			final SortedSet<QueryParameter> params = createSortedParameters(canonicalURI.getRawQuery());
			final String queryString;
			String canonicalParams = canonicalize(params);
			queryString = (canonicalParams.isEmpty() ? "" : "?" + canonicalParams);

			/* Add starting slash if needed */
			if (path.length() == 0) {
				path = "/" + path;
			}

			/* Drop default port: example.com:80 -> example.com */
			int port = canonicalURI.getPort();
			if (isDefaultPort(canonicalURI.getScheme(), port)) {
				port = -1;
			}

			/* Lowercasing protocol and host */
			String protocol = canonicalURI.getScheme().toLowerCase();
			String host = canonicalURI.getHost().toLowerCase();
			String pathAndQueryString = normalizePath(path) + queryString;

			URL result = new URL(protocol, host, port, pathAndQueryString);
			return result.toExternalForm();

		} catch (Exception ex) {
			log.warn("Error while Processing URL [" + url + "] in the spidering process (on base " + baseURL + "): "
					+ ex.getMessage());
			return null;
		}
	}
484866
function cleanUrl(url) {
    "use strict";
    if (url.toLowerCase().indexOf('http') !== 0) {
        return url;
    }
    var a = document.createElement('a');
    a.href = url;
    return a.href;
}
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;
}
1201526
function resolveOrigin(url) {
  var a = document.createElement('a');
  a.href = url;
  var protocol = a.protocol.length > 4 ? a.protocol : window.location.protocol;
  var host = a.host.length ? a.port === '80' || a.port === '443' ? a.hostname : a.host : window.location.host;
  return a.origin || protocol + "//" + host;
}
175430
function fixRelativeUrls(cssText, href) {
	var base = resolveRelativeUrl(href, document.baseURI);
	return cssText.replace(URL_VALUE_REGEXP, function(match, quote, url1, url2) {
		var url = url1 || url2;
		if (!url) {
			return match;
		}
		return 'url(' + (quote || '"') + resolveRelativeUrl(url, base) + (quote || '"') + ')';
	});
}
1192956
function toRepoUrl(url) {
  if (url.startsWith('git@')) {
    if (argv.useSSH) {
      return url;
    }
    // have an ssh url need an http url
    const m = url.match(/(https?:\/\/([^/]+)\/|git@(.+):)([\w\d-_/]+)(.git)?/);
    return `https://${m[3]}/${m[4]}.git`;
  }
  if (url.startsWith('http')) {
    if (!argv.useSSH) {
      return url;
    }
    // have a http url need an ssh url
    const m = url.match(/(https?:\/\/([^/]+)\/|git@(.+):)([\w\d-_/]+)(.git)?/);
    return `git@${m[2]}:${m[4]}.git`;
  }
  if (!url.includes('/')) {
    url = `Caleydo/${url}`;
  }
  if (argv.useSSH) {
    return `git@github.com:${url}.git`;
  }
  return `https://github.com/${url}.git`;
}
691424
function(url) {
			var index = url ? url.lastIndexOf('/') : -1;
			return index == -1 ? url : url.substring(0, index + 1);
		}
851925
function resolve(ref, context) {
    if (typeof ref !== 'string') return ref;
    if (/^#/.test(ref)) { ref = (context._href || '/') + ref; }
    return generator.fragment$[ref];
  }
361791
def resolve_url(href_str, absolute_url_str)
      if absolute_url_str.class <= URI::Generic
        absolute_url = absolute_url_str.dup
      else
        begin
          absolute_url = URI(absolute_url_str).dup
        rescue URI::InvalidURIError
          raise ArgumentError, "#{absolute_url_str} must be represent a valid relative or absolute URI" 
        end
      end
      raise ArgumentError, "#{absolute_url} must be absolute" unless absolute_url.absolute?
      if href_str.class <= URI::Generic
        href = href_str.dup
      else
        begin
          href = URI(href_str).dup
        rescue URI::InvalidURIError
          raise ArgumentError, "#{href_str} must be represent a valid relative or absolute URI"
        end
      end

      # return :href if :href is already absolute
      return href.to_s if href.absolute?

      #TODO: edge cases, see [issue #8](https://github.com/propublica/upton/issues/8)
      URI.join(absolute_url.to_s, href.to_s).to_s
    end