Skip to content

Commit d09af8f

Browse files
vadmestekannappanr
authored andcommitted
Fix detecting a valid endpoint with new Python versions (#836)
1 parent 4edf6c6 commit d09af8f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

minio/helpers.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,21 @@ def is_valid_endpoint(endpoint):
288288
otherwise.
289289
"""
290290
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:
292303
raise InvalidEndpointError('Hostname cannot have a scheme.')
293304

294-
hostname = endpoint.split(':')[0]
305+
hostname = u.hostname
295306
if hostname is None:
296307
raise InvalidEndpointError('Hostname cannot be empty.')
297308

0 commit comments

Comments
 (0)