https://url.spec.whatwg.org/#url-miscellaneous
1986
function getDefaultPortFromScheme( scheme ) {
  var port = null;
  if ( scheme === 'ftp') {
    port = 21;
  }
  else if ( scheme === 'gopher' ) {
    port = 70;
  }
  else if ( scheme === 'http' || scheme === 'ws' ) {
    port = 80;
  }
  else if ( scheme === 'https' || scheme === 'wss' ) {
    port = 443;
  }
  return port;
}
1158911
private List<String> buildUrls(List<String> references) {
		List<String> urls = new ArrayList<String>(references.size());
		for (String url : references) {
			if (url.toUpperCase().startsWith("RFC")) {
				url = RFC_REFERENCE_BASE_URL + url;
			} else if (url.startsWith("http")) {
				// already an URL so do nothing
			} else {
				url = MIME_TYPE_REFERENCE_BASE_URL + "#" + url;
			}
			urls.add(url);
		}
		return urls;
	}
254461
public static String buildHelpPageUrl(String helpPage) {
        try {
            if (helpPage.matches("[hH][tT][tT][pP][sS]?://.*")) {
                log.debug("Help page URL found, skipping building link to "+WIKI_BASE);
                return helpPage;
            }
        } catch (PatternSyntaxException ex) {
            log.warn("Invalid regex", ex);
        }

        if (helpPage.endsWith("Gui")) {
            helpPage = helpPage.substring(0, helpPage.length() - 3);
        }
        return WIKI_BASE + helpPage + "/?utm_source=jmeter&utm_medium=helplink&utm_campaign=" + helpPage;
    }
1240940
function buildHttpURL(uri) {
    var port     = weinre_port
    var pathname = weinre_pathname

    if (pathname == "/index.html") pathname = "/"

    if (weinre_protocol == "file:") {
        return uri
    }

    else if (weinre_protocol == "http:") {
        if (port != "") port = ":" + port

        return weinre_protocol + "//" + weinre_host + port + pathname + uri
    }

    else if (weinre_protocol == "https:") {
        if (port != "") port = ":" + port

        return weinre_protocol + "//" + weinre_host + port + pathname + uri
    }
}
551488
def chopurl(url):
    '''
    
    '''
    ret = {}
    if url.find('://') == -1:
        raise s_exc.BadUrl(':// not found in [{}]!'.format(url))

    scheme, remain = url.split('://', 1)
    ret['scheme'] = scheme.lower()

    # carve query params from the end
    if remain.find('?') != -1:
        query = {}
        remain, queryrem = remain.split('?', 1)

        for qkey in queryrem.split('&'):
            qval = None
            if qkey.find('=') != -1:
                qkey, qval = qkey.split('=', 1)

            query[qkey] = qval

        ret['query'] = query

    pathrem = ''
    slashoff = remain.find('/')
    if slashoff != -1:
        pathrem = remain[slashoff:]
        remain = remain[:slashoff]

    # detect user[:passwd]@netloc syntax
    if remain.find('@') != -1:
        user, remain = remain.rsplit('@', 1)
        if user.find(':') != -1:
            user, passwd = user.split(':', 1)
            ret['passwd'] = passwd

        ret['user'] = user

    # remain should be down to host[:port]

    # detect ipv6 [addr]:port syntax
    if remain.startswith('['):
        hostrem, portstr = remain.rsplit(':', 1)
        ret['port'] = int(portstr)
        ret['host'] = hostrem[1:-1]

    # detect ipv6 without port syntax
    elif remain.count(':') > 1:
        ret['host'] = remain

    # regular old host or host:port syntax
    else:

        if remain.find(':') != -1:
            remain, portstr = remain.split(':', 1)
            ret['port'] = int(portstr)

        ret['host'] = remain

    ret['path'] = pathrem
    return ret
1184695
function _convertUrlsToLinks(str) {
    return str.replace(URL_REG_EXP, function(match, url) {
      var punctuation = (url.match(TRAILING_CHAR_REG_EXP) || [])[1] || "",
          opening     = BRACKETS[punctuation];
      url = url.replace(TRAILING_CHAR_REG_EXP, "");

      if (url.split(opening).length > url.split(punctuation).length) {
        url = url + punctuation;
        punctuation = "";
      }
      var realUrl    = url,
          displayUrl = url;
      if (url.length > MAX_DISPLAY_LENGTH) {
        displayUrl = displayUrl.substr(0, MAX_DISPLAY_LENGTH) + "...";
      }
      // Add http prefix if necessary
      if (realUrl.substr(0, 4) === "www.") {
        realUrl = "http://" + realUrl;
      }

      return '<a href="' + realUrl + '">' + displayUrl + '</a>' + punctuation;
    });
  }
910777
def _url_matches(self, url, other, match_querystring=False):
        '''
        
        '''
        if not match_querystring:
            other = other.split('?', 1)[0]

        if responses._is_string(url):
            if responses._has_unicode(url):
                url = responses._clean_unicode(url)
                if not isinstance(other, six.text_type):
                    other = other.encode('ascii').decode('utf8')
            return self._url_matches_strict(url, other)
        elif isinstance(url, responses.Pattern) and url.match(other):
            return True
        else:
            return False
558589
def is_external_url(self, url, site_url):
        
        url_splitted = urlsplit(url)
        if not url_splitted.netloc:
            return False
        return url_splitted.netloc != urlsplit(site_url).netloc
269586
def build_url                 
      parts = []
      uri   = ""
      parts << "/#{@version}"         if @version
      parts << "/#{@domain}"          if @domain
      parts << "/#{@service}"         if @service
      uri   =  parts.join("")
      parts << "?"
      parts << "format=#{@format}"
      parts << "&#{authentication_params(uri)}"
      parts << "#{format_parameters}" if @parameters
      @url = parts.join("")
    end
884097
def url_spec(transmute_path, handler, *args, **kwargs):
    
    p = _to_tornado_pattern(transmute_path)
    for m in METHODS:
        method = getattr(handler, m)
        if hasattr(method, "transmute_func"):
            method.transmute_func.paths.add(transmute_path)
    return tornado.web.URLSpec(
        p, handler,
        *args, **kwargs
    )
933904
function _resolveUrl(base, url) {
    var /** @type {?} */ parts = _split(encodeURI(url));
    var /** @type {?} */ baseParts = _split(base);
    if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["c" /* isPresent */])(parts[_ComponentIndex.Scheme])) {
        return _joinAndCanonicalizePath(parts);
    }
    else {
        parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
    }
    for (var /** @type {?} */ i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
        if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(parts[i])) {
            parts[i] = baseParts[i];
        }
    }
    if (parts[_ComponentIndex.Path][0] == '/') {
        return _joinAndCanonicalizePath(parts);
    }
    var /** @type {?} */ path = baseParts[_ComponentIndex.Path];
    if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__facade_lang__["d" /* isBlank */])(path))
        path = '/';
    var /** @type {?} */ index = path.lastIndexOf('/');
    path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
    parts[_ComponentIndex.Path] = path;
    return _joinAndCanonicalizePath(parts);
}
701865
def hashtag_links(uri, s):
    
    for tag, after in hashtag_re.findall(s):
        _uri = '/' + (uri or "").lstrip("/") + quote(tag)
        link = '<a href="{}">#{}</a>{}'.format(_uri.lower(), tag, after)
        s = s.replace('#' + tag, link)
    return s
862302
def mentions_links(uri, s):
    
    for username, after in mentions_re.findall(s):
        _uri = '/' + (uri or "").lstrip("/") + quote(username)
        link = '<a href="{}">@{}</a>{}'.format(_uri.lower(), username, after)
        s = s.replace('@' + username, link)
    return s
523112
def url
      sch = @options[:ssl] ? "https" : "http"
      hosts = Array(@options[:host])
      @url ||= if hosts.first.include?(":")
                 URI("#{sch}://[#{hosts.first}]:#{port}").to_s
               else
                 URI("#{sch}://#{hosts.first}:#{port}").to_s
               end
    end
665039
def get_urls(self):
        
        urls = []

        for action in self.get_extra_actions():
            regex = r'^{}/$'.format(self._get_action_href(action))
            view = self.admin_site.admin_view(action)
            urls.append(url(regex, view))

        return urls + super(ExtraActionsMixin, self).get_urls()
54982
def _IsValidUrl(self, url):
    
    parsed_url = urlparse.urlparse(url)
    return parsed_url.scheme in self._SUPPORTED_URL_SCHEMES
300988
function (url) {
            return url
                .replace(/[\/]+/g, '/')
                .replace(/\/\?/g, '?')
                .replace(/\/\#/g, '#')
                .replace(/\:\//g, '://');
        }