Skip to content

Commit

Permalink
Fix #386: Convert host to lowercase on URL building
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Jul 26, 2020
1 parent 3ecfc65 commit a0cdc15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/386.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert host to lowercase on URL building.
3 changes: 3 additions & 0 deletions yarl/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ def _encode_host(cls, host):
ip, sep, zone = host.partition("%")
ip = ip_address(ip)
except ValueError:
host = host.lower()
# IDNA encoding is slow,
# skip it for ASCII-only strings
# Don't move the check into _idna_encode() helper
Expand All @@ -729,6 +730,8 @@ def _encode_host(cls, host):
ip, sep, zone = host.partition("%")
ip = ip_address(ip)
except ValueError:
host = host.lower()

for char in host:
if char > "\x7f":
break
Expand Down

0 comments on commit a0cdc15

Please sign in to comment.