def rubygems_homepage_url(name, version=None):
    """
    Return a Rubygems.org homepage URL given a ``name`` and optional
    ``version``, or None if ``name`` is empty.

    For example:
    >>> url = rubygems_homepage_url(name='mocha', version='1.7.0')
    >>> assert url == 'https://rubygems.org/gems/mocha/versions/1.7.0'

    >>> url = rubygems_homepage_url(name='mocha')
    >>> assert url == 'https://rubygems.org/gems/mocha'
    """
    if not name:
        return
    if version:
        version = version.strip().strip('/')
        return f'https://rubygems.org/gems/{name}/versions/{version}'
    else:
        return f'https://rubygems.org/gems/{name}'