def normalize_url(self, url, charset='utf-8'): url = encode(url, charset, 'ignore') scheme, netloc, path, qs, anchor = urlsplit(url) path = quote(path, b'/%') qs = quote_plus(qs, b':&%=') return urlparse.urlunsplit((scheme, netloc, path, qs, anchor))
def normalize_url(self, url, charset="utf-8"): url = encode(url, charset, "ignore") scheme, netloc, path, qs, anchor = urlsplit(url) path = quote(path, b"/%") qs = quote_plus(qs, b":&%=") return urlparse.urlunsplit((scheme, netloc, path, qs, anchor))
def normalize_url(self, url, charset='utf-8'): url = encode(url, charset, 'ignore') scheme, netloc, path, qs, anchor = urlsplit(url) # Encode to utf8 to prevent urllib KeyError path = encode(path, charset, 'ignore') path = quote(path, '/%') qs = quote_plus(qs, ':&%=') return urlparse.urlunsplit((scheme, netloc, path, qs, anchor))