def urljoin(*atoms):
    r"""Return the given path \*atoms, joined into a single URL.

    This will correctly join a SCRIPT_NAME and PATH_INFO into the
    original URL, even if either atom is blank.
    """
    url = '/'.join([x for x in atoms if x])
    while '//' in url:
        url = url.replace('//', '/')
    # Special-case the final url of "", and return "/" instead.
    return url or '/'
Return the given path \*atoms, joined into a single URL.

    This will correctly join a SCRIPT_NAME and PATH_INFO into the
    original URL, even if either atom is blank.
    
cherrypy/lib/httputil.py