Python3: fix decode_parts function

This commit is contained in:
Petr Dlouhý 2018-01-05 20:05:17 +01:00 committed by Chris Mayo
parent 9fb1cc98c7
commit 0d7a2cac72

View file

@ -350,11 +350,14 @@ def url_norm (url, encoding=None):
urlparts[2] = url_fix_wayback_query(urlparts[2]) # unencode colon in http[s]:// in wayback path
urlparts[4] = url_quote_part(urlparts[4], safechars="!$&'()*+,-./;=?@_~", encoding=encoding) # anchor
res = urlunsplit(urlparts)
if url.endswith('#') and not urlparts[4]:
if decode_for_unquote(url).endswith('#') and not urlparts[4]:
# re-append trailing empty fragment
res += '#'
if encode_unicode:
res = unicode(res)
try:
res = unicode(res)
except NameError:
pass
return (res, is_idn)