(url)
return urlunparse(parsed)
Automatically convert an URL like 'unix:///var/run/docker.sock/info' to 'unix://%2Fvar%2Frun%2Fdocker.sock/info'.

    For user experience purposes, since `requests-unixsocket` only accepts the latter form.
Automatically convert an URL like 'unix:///var/run/docker.sock/info' to 'unix://%2Fvar%2Frun%2Fdocker.sock/info'.
Automatically convert an URL like unix : /// var / run / docker . sock / info to unix : // %2Fvar%2Frun%2Fdocker . sock / info .
def quote_uds_url(url):
    # type: (str) -> str
    """
    Automatically convert an URL like 'unix:///var/run/docker.sock/info' to 'unix://%2Fvar%2Frun%2Fdocker.sock/info'.

    For user experience purposes, since `requests-unixsocket` only accepts the latter form.
    """
    parsed = urlparse(url)

    # When passing an UDS path URL, `netloc` is empty and `path` contains everything that's after '://'.
    # We want to extract the socket path from the URL path, and percent-encode it, and set it as the `netloc`.
    # For now we assume that UDS paths end in '.sock'. This is by far the most common convention.
    uds_path_head, has_dot_sock, path = parsed.path.partition('.sock')
    if not has_dot_sock:
        return url

    uds_path = '{}.sock'.format(uds_path_head)
    netloc = quote(uds_path, safe='')
    parsed = parsed._replace(netloc=netloc, path=path)

    return urlunparse(parsed)
def quote_uds_url ( url ) : # type: (str) -> str parsed = urlparse ( url ) # When passing an UDS path URL, `netloc` is empty and `path` contains everything that's after '://'. # We want to extract the socket path from the URL path, and percent-encode it, and set it as the `netloc`. # For now we assume that UDS paths end in '.sock'. This is by far the most common convention. uds_path_head , has_dot_sock , path = parsed . path . partition ( '.sock' ) if not has_dot_sock : return url uds_path = '{}.sock' . format ( uds_path_head ) netloc = quote ( uds_path , safe = '' ) parsed = parsed . _replace ( netloc = netloc , path = path ) return urlunparse ( parsed )