import re


def remove_trailing_slashes(filepath: str) -> str:
    """
    Removes trailing slashes from a directory path or full filepath

    Examples:
        remove_trailing_slashes("/my/path/") == "my/path"
        remove_trailing_slashes("my/path/") == "my/path"
        remove_trailing_slashes("/path/to/myfile.pdf") == "path/to/myfile.pdf"
    """
    return re.sub(r"^\/|\/$", "", filepath)