def categorize(contenttype: str):
    """Return 'cbor', 'json' or 'link-format' if the content type indicates it
    is that format itself or derived from it."""

    media_type, *_ = contenttype.split(';')
    _, _, subtype = media_type.partition('/')

    if subtype == 'cbor' or subtype.endswith('+cbor'):
        return 'cbor'

    if subtype == 'json' or subtype.endswith('+json'):
        return 'json'

    if media_type == 'application/link-format':
        return 'link-format'

    return None