import re


def parse(specification):
    """Parse optional configuration values.

    This function parses the given ``specification`` value into a name and
    a dictionary of key/value configuration pairs if specified.

    Args:
        specification (str): The specification to parse.

    Returns:
        A tuple of the parse name and configuration if provided, otherwise
        ``None``.

    Example:
        The following configuration specification::

        configuration-example:first=something,second="another thing"

        Will be parsed as::

        (
            'configuration-example',
            {
                'first': 'something',
                'second': 'another thing'
            }
        )
    """

    result = specification.split(":", 1)

    if len(result) == 1:
        return {"name": result[0], "configuration": {}}

    name, configuration = result

    name = name.strip('"')

    configuration = dict(re.findall(r'([^,]+)=(["\'].*?["\']|[^,]+)', configuration))
    configuration = {k: v.strip("\"'") for k, v in configuration.items()}

    return {"name": name, "configuration": configuration}