def METHOD_NAME(project_git_url, dataset_uri):
    """Passing token is safe if project and dataset belong to the same deployment."""
    project_host = os.environ.get("RENKU_DOMAIN") or GitURL.parse(project_git_url).hostname
    dataset_host = urllib.parse.urlparse(dataset_uri).netloc
    # NOTE: URLs changed from domain/gitlab to gitlab.domain when moving to cloud native gitlab
    if project_host.startswith("gitlab.") and not dataset_host.startswith("gitlab."):
        project_host = project_host.replace("gitlab.", "", 1)
    return project_host == dataset_host