code: def to_dir_path_url(url_info: URLInfo) -> str:
      '''Return URL string with the path replaced with directory only.'''
      dir_name = posixpath.dirname(url_info.path)
  
      if not dir_name.endswith('/'):
          url_template = 'ftp://{}{}/'
      else:
          url_template = 'ftp://{}{}'
  
      return url_template.format(url_info.hostname_with_port, dir_namef to_dir_path_url(url_info: URLInfo) -> str:
      '''Return URL string with the path replaced with directory only.'''
      dir_name = posixpath.dirname(url_info.path)
  
      if not dir_name.endswith('/'):
          url_template = 'ftp://{}{}/'
      else:
          url_template = 'ftp://{}{}'
  
      return url_template.format(url_info.hostname_with_port, dir_name)
docs: Return URL string with the path replaced with directory only.