import re


def ellipsicate(message: str, max_length: int = 40, strip: bool = True) -> str:
    """Return a shortened version of a string if it exceeds max_length.

    This will turn 'bizbazfrobnicator' into "biz ... tor".
    """
    msg = re.sub(r'\s+', ' ', str(message))  # only allow ' ' for whitespace
    if strip:
        msg = msg.strip()
    if len(msg) <= max_length:
        return msg
    snip_length = int((max_length - 5) / 2)  # ellipsis padded with spaces
    return str(msg[:snip_length] + ' ... ' + msg[-snip_length:])