Skip to content

Commit

Permalink
DRY up MultiDomainBasicAuth some more.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerdonek committed Oct 30, 2018
1 parent a434431 commit f54b68f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ def __init__(self, prompting=True):
def __call__(self, req):
parsed = urllib_parse.urlparse(req.url)

# Get the netloc without any embedded credentials
netloc = parsed.netloc.rsplit("@", 1)[-1]
# Split the credentials from the netloc.
netloc, url_user_password = split_auth_from_netloc(parsed.netloc)

# Set the url of the request to the url without any credentials
req.url = urllib_parse.urlunparse(parsed[:1] + (netloc,) + parsed[2:])

# Use any stored credentials that we have for this netloc
username, password = self.passwords.get(netloc, (None, None))

# Extract credentials embedded in the url if we have none stored
# Use the credentials embedded in the url if we have none stored
if username is None:
username, password = split_auth_from_netloc(parsed.netloc)[1]
username, password = url_user_password

# Get creds from netrc if we still don't have them
if username is None and password is None:
Expand Down

0 comments on commit f54b68f

Please sign in to comment.