def normalize_url(url):
    """Return url after stripping trailing .json and trailing slashes."""
    if url.endswith('.json'):
        url = url[:-5]
    if url.endswith('/'):
        url = url[:-1]
    return url
Return url after stripping trailing .json and trailing slashes.
rtv/packages/praw/helpers.py