Cleans the url for protocol prefix and trailing slash and replaces special characters
        with the given replacement.

        :param url: The url of the request.
        :param replacement: A string that is used to replace special characters.
2220
def clean_url(url, replacement='_'):
        
        cleaned = re.sub(r'/$', '', re.sub(r'https?://', '', url))
        for character in '/ _ ? & : ; %'.split():
            cleaned = cleaned.replace(character, replacement)
        return cleaned
1085347
def _normalize_check_url(self, check_url):
        

        # TODO: Write tests for this method
        split_url = urlsplit(check_url)
        host = splitport(split_url.path or split_url.netloc)[0]
        return '{0}://{1}:{2}'.format(self.scheme, host, self.port)
882450
def url_quote_plus(s, charset='utf-8', safe=''):
    
    if isinstance(s, unicode):
        s = s.encode(charset)
    elif not isinstance(s, str):
        s = str(s)
    return _quote_plus(s, safe=safe)
571058
def clean_url(url)
      uri = URI.parse(url)
      uri.query = CGI.parse(uri.query || '').reject { |k| k == 'api_key' }.to_query
      uri.to_s
    end
475191
def _clean_url(url):
    ''' 

    '''
    if url == 'default':
        url = DEFAULT_SERVER_HTTP_URL

    if url.startswith("ws"):
        raise ValueError("url should be the http or https URL for the server, not the websocket URL")

    return url.rstrip("/")
524785
def uriunsplit(uri):
    
    (scheme, authority, path, query, fragment) = uri
    result = ''
    if scheme:
        result += scheme + ':'
    if authority:
        result += '//' + authority
    if path:
        result += path
    if query:
        result += '?' + query
    if fragment:
        result += '#' + fragment
    return result
563895
def url_quote_plus(string, charset='utf-8', errors='strict', safe=''):
    
    return url_quote(string, charset, errors, safe + ' ').replace(' ', '+')
679212
def update_url_params(url, replace_all=False, **url_params):
    

    # Ensure 'replace_all' can be sent as a url param
    if not (replace_all is True or replace_all is False):
        url_params['replace_all'] = replace_all

    if not url or not url_params:
        return url or None

    scheme, netloc, url_path, url_query, fragment = _urlsplit(url)

    if replace_all is True:
        url_query = url_params
    else:
        url_query = _parse_qs(url_query)
        url_query.update(url_params)

    return _urlunsplit((scheme, netloc, url_path, _unquote(_urlencode(url_query, doseq=True)), fragment))
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;
}
1373437
function normalizeUrl(url) {
  if (!IS_ABSOLUTE.test(url)) {
    return (0, _normalizeUrl2['default'])(url).replace('http://', '');
  } else {
    return (0, _normalizeUrl2['default'])(url);
  }
}
1203059
private static String normalize(String url) {
        if (StringUtils.isBlank(url)) {
            return null;
        }
        // Strip "/tree/..."
        if (url.contains("/tree/")) {
            url = url.replaceFirst("/tree/.*$", "");
        }
        if (!url.endsWith("/")) {
            url += '/';
        }
        return url;
    }
1634
def match(self, url: str) -> RouteResolved:
        
        url = normalize_url(url)
        parts = self._deconstruct_url(url)
        return self._match(parts)
777409
def fix_url(url):
    
    if url is None:
        return None

    url = url.strip()

    if url and not urlparse(url).scheme:
        url = "http://" + url

    return url
171578
def sanitize_url(url):
    """"""
    parts = urlparse(url)
    if parts.password is None:
        return url
    host_info = parts.netloc.rsplit('@', 1)[-1]
    parts = parts._replace(netloc='{}:{}@{}'.format(
        parts.username, REDACTED, host_info))
    return parts.geturl()
816177
def _url(self, url):
        

        protocol = 'https' if self.https else 'http'
        return '{0}://{1}/spaces/{2}{3}'.format(
            protocol,
            self.api_url,
            self.space_id,
            url
        )
762119
def _replace(self, url):
        
        segments = url.split('/')
        if segments[0] == '':
            root = self.rootURL(self.request)
            if segments[1] == 'Mantissa':
                root = root.child('static').child('mantissa-base')
                segments = segments[2:]
            elif segments[1] in self.installedOfferingNames:
                root = root.child('static').child(segments[1])
                segments = segments[2:]
            for seg in segments:
                root = root.child(seg)
            return str(root)
        return url
383385
protected static String cleanupUrl(final String url) {
        if (url == null) {
            return null;
        }
        val jsessionPosition = url.indexOf(";jsession");
        if (jsessionPosition == -1) {
            return url;
        }
        val questionMarkPosition = url.indexOf('?');
        if (questionMarkPosition < jsessionPosition) {
            return url.substring(0, url.indexOf(";jsession"));
        }
        return url.substring(0, jsessionPosition) + url.substring(questionMarkPosition);
    }