File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ def host(self) -> str:
170170 """
171171 The URL host as a string.
172172 Always normalized to lowercase, with IDNA hosts decoded into unicode.
173+ Invalid IDNA encodings are kept in their original xn-- form.
173174
174175 Examples:
175176
@@ -182,13 +183,19 @@ def host(self) -> str:
182183 url = httpx.URL("http://xn--fiqs8s.icom.museum")
183184 assert url.host == "中国.icom.museum"
184185
186+ url = httpx.URL("https://xn--ls8h.la/")
187+ assert url.host == "xn--ls8h.la"
188+
185189 url = httpx.URL("https://[::ffff:192.168.0.1]")
186190 assert url.host == "::ffff:192.168.0.1"
187191 """
188192 host : str = self ._uri_reference .host
189193
190194 if host .startswith ("xn--" ):
191- host = idna .decode (host )
195+ try :
196+ host = idna .decode (host )
197+ except idna .IDNAError :
198+ pass
192199
193200 return host
194201
You can’t perform that action at this time.
0 commit comments