def validate_url(self, url):
url_path = urllib.quote(url.path, safe=b"/%")
url_query = urllib.quote(url.query, safe=b"?=&")
url = ParseResult(url.scheme, url.netloc, url_path,
url.params, url_query, url.fragment)
has_hostname = url.hostname is not None and len(url.hostname) > 0
has_http_scheme = url.scheme in ("http", "https")
has_path = not len(url.path) or url.path.startswith("/")
if not (has_hostname and has_http_scheme and has_path):
raise NotSupported("invalid url: %s" % repr(url))
return url
评论列表
文章目录