File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -288,10 +288,21 @@ def is_valid_endpoint(endpoint):
288
288
otherwise.
289
289
"""
290
290
try :
291
- if urlsplit (endpoint ).scheme :
291
+ if not '//' in endpoint :
292
+ # Having '//' in the beginning of the endpoint enforce
293
+ # urlsplit to consider the endpoint as a netloc according
294
+ # to this quote in docs.python.org/3/library/urllib.parse.html:
295
+ # Following the syntax specifications in RFC 1808, urlparse
296
+ # recognizes a netloc only if it is properly introduced by ‘//’.
297
+ # Otherwise the input is presumed to be a relative URL and thus
298
+ # to start with a path component.
299
+ endpoint = '//' + endpoint
300
+
301
+ u = urlsplit (endpoint )
302
+ if u .scheme :
292
303
raise InvalidEndpointError ('Hostname cannot have a scheme.' )
293
304
294
- hostname = endpoint . split ( ':' )[ 0 ]
305
+ hostname = u . hostname
295
306
if hostname is None :
296
307
raise InvalidEndpointError ('Hostname cannot be empty.' )
297
308
You can’t perform that action at this time.
0 commit comments