def remove_trailing_string(content, trailing):
    if content.endswith(trailing) and content != trailing:
        return content[:-len(trailing)]
    return content
Strip trailing component `trailing` from `content` if it exists.
dataset/ETHPy150Open tomchristie/django-rest-framework/rest_framework/utils/formatting.py/remove_trailing_string