def strip_end(text: str, suffix: str, case_insensitive: bool = False) -> str:
    """Strips the suffix from a string if present.

    https://stackoverflow.com/a/1038999

    :param text: String to check for suffix
    :param suffix: Suffix to look for.
    :param case_insensitive: Do a case insensitive match. Defaults to False.
    :returns: The resulting string.
    """
    if case_insensitive:
        if not text.lower().endswith(suffix.lower()):
            return text
    else:
        if not text.endswith(suffix):
            return text
    return text[: len(text) - len(suffix)]