code: def is_valid_url(url):
      
      from .misc import to_text
  
      if not url:
          return url
      pieces = urllib_parse.urlparse(to_text(url))
      return all([pieces.scheme, pieces.netloc])
docs: Checks if a given string is an url