

def _graceful_relative_url(base_url, url):
    '\n    Return a graceful link for a URL relative to a base URL.\n\n    * If they are the same, return an empty string.\n    * If the have the same scheme and hostname, return the path & query params.\n    * Otherwise return the full URL.\n    '
    if (url == base_url):
        return ''
    base_prefix = ('%s://%s' % urlparse.urlparse((base_url or ''))[0:2])
    url_prefix = ('%s://%s' % urlparse.urlparse((url or ''))[0:2])
    if ((base_prefix == url_prefix) and (url_prefix != '://')):
        return url[len(url_prefix):]
    return url

dataset/ETHPy150Open core-api/python-client/coreapi/codecs/corejson.py _graceful_relative_url/original