Skip to content

Commit

Permalink
Robustify simple absolute URL check slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed May 5, 2020
1 parent a8a24cf commit a46a09c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions optimade/validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def __init__(self, base_url: str, max_retries=5):
self.max_retries = max_retries

def get(self, request: str):
""" Makes the given request, with a number of retries if being rate limited.
""" Makes the given request, with a number of retries if being rate limited. The
request will be prepended with the `base_url` unless the request appears to be an
absolute URL (i.e. starts with `http://` or `https://`).
Parameters:
request (str): the request to make against the base URL of this client.
Expand All @@ -114,7 +116,7 @@ def get(self, request: str):
"""
if request:
if any(request.startswith(scheme) for scheme in ("http", "https")):
if any(request.startswith(scheme) for scheme in ("http://", "https://")):
self.last_request = request
else:
self.last_request = f"{self.base_url}/{request}".replace("\n", "")
Expand Down

0 comments on commit a46a09c

Please sign in to comment.