import re


def _egg_link_name(raw_name: str) -> str:
    """
    Convert a Name metadata value to a .egg-link name, by applying
    the same substitution as pkg_resources's safe_name function.
    Note: we cannot use canonicalize_name because it has a different logic.
    """
    return re.sub("[^A-Za-z0-9.]+", "-", raw_name) + ".egg-link"