code: def fix_reference_url(url):
      
      new_url = url
  
      new_url = fix_url_bars_instead_of_slashes(new_url)
  
      new_url = fix_url_add_http_if_missing(new_url)
  
      new_url = fix_url_replace_tilde(new_url)
  
      try:
          rfc3987.parse(new_url, rule="URI")
          return new_url
      except ValueError:
          return url
docs: Used to parse an incorect url to try to fix it with the most common ocurrences for errors.
      If the fixed url is still incorrect, it returns ``None``.
  
      Returns:
          String containing the fixed url or the original one if it could not be fixed.