def JoinURL(base_url, *args):
  """Join two or more parts of a URL.

  Args:
    base_url: str, base URL like https://example.com/foo.
    *args: str arguments to join to the base URL, like 'bar' or '/bar'.
  Returns:
    String URL joined sanely with single slashes separating URL parts.
  """
  url = base_url
  for part in args:
    if part.startswith('/'):
      part = part[1:]

    if not url or url.endswith('/'):
      url +=  part
    else:
      url += '/' + part
  return url