Skip to content

Commit

Permalink
Fix detecting a valid endpoint with new Python versions (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste authored and kannappanr committed Dec 24, 2019
1 parent 4edf6c6 commit d09af8f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions minio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,21 @@ def is_valid_endpoint(endpoint):
otherwise.
"""
try:
if urlsplit(endpoint).scheme:
if not '//' in endpoint:
# Having '//' in the beginning of the endpoint enforce
# urlsplit to consider the endpoint as a netloc according
# to this quote in docs.python.org/3/library/urllib.parse.html:
# Following the syntax specifications in RFC 1808, urlparse
# recognizes a netloc only if it is properly introduced by ‘//’.
# Otherwise the input is presumed to be a relative URL and thus
# to start with a path component.
endpoint = '//' + endpoint

u = urlsplit(endpoint)
if u.scheme:
raise InvalidEndpointError('Hostname cannot have a scheme.')

hostname = endpoint.split(':')[0]
hostname = u.hostname
if hostname is None:
raise InvalidEndpointError('Hostname cannot be empty.')

Expand Down

0 comments on commit d09af8f

Please sign in to comment.