def clean_url(url, root=True, protocol='http'):
    """
    Remove trailing/leading slashes from a url
    params
        root
            if the url starts at the domain level
        protocol
            ignored if root=False
            what protocol should be added to the start of a url
    """
    out = '/'.join(filter(None, url.split('/')))
    if root:
        if ':/' in out:
            out = out.replace(':/', '://')
        else:
            out = '://'.join((protocol, out))
    return out