def urljoin(*parts):
    """
    Join chunks of a URL together.

    The main thing this does is ensure each chunk is separated by exactly one /.

    :param parts: URL components.
    :return: Unified URL string
    """
    def _gen(parts):
        prev = None
        for part in parts:
            if not part:
                continue
            if not prev:
                prev = part
            elif (prev[-1] == '/') != (part[0] == '/'):  # Exactly one slash was present
                prev = part
            # At this point, either zero or two slashes are present.  Which is it?
            elif part[0] == '/':  # Two slashes.
                prev = part[1:]
            else:  # No slashes.
                yield '/'
                prev = part
            yield prev

    return "".join(part for part in _gen(parts))