def ensure_trailing_slash(url: str) -> str:
    """When comparing URLs, e.g. "http://example.com/" and "http://example.com", use this method to normalise the comparison."""

    if "?" in url:  # If the URL contains a parameter (e.g. https://example.com/search?page=1), ignore trailing slash.
        return url
    return url if url[-1] == "/" else f"{url}/"