:return: the url without the query or fragment segments

def get_base_url(url, include_path=False):
    """ :return: the url without the query or fragment segments """

    if not url:
        return None

    parts = _urlsplit(url)
    base_url = _urlunsplit((
        parts.scheme, parts.netloc, (parts.path if include_path else ''), None, None
    ))

    return base_url if base_url.endswith('/') else base_url + '/'