Skip to content

Commit

Permalink
Change: Format urls properly for urllib.parse.urljoin
Browse files Browse the repository at this point in the history
  • Loading branch information
erenes committed Apr 10, 2021
1 parent 4887a9a commit 96fa301
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bananas_cli/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def authenticate(session, client_id, audience):
bearer_token = f.read()

session.set_header("Authorization", f"Bearer {bearer_token}")
status, data = await session.get("/user")
status, data = await session.get("user")
if status == 200:
return

Expand All @@ -102,7 +102,7 @@ async def authenticate(session, client_id, audience):
code_challenge = base64.urlsafe_b64encode(digest).decode().rstrip("=")

status, data = await session.get(
"/user/authorize?"
"user/authorize?"
f"audience={audience}&"
"redirect_uri=http%3A%2F%2Flocalhost%3A3977%2F&"
"response_type=code&"
Expand Down
2 changes: 1 addition & 1 deletion bananas_cli/commands/list_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@pass_session
@task
async def list_self(session):
status, data = await session.get("/package/self")
status, data = await session.get("package/self")
if status != 200:
log.error(f"Server returned invalid status code {status}: {data}")
raise Exit
Expand Down
6 changes: 3 additions & 3 deletions bananas_cli/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def upload(session, version, name, description, url, license, files):

starting_part = "/".join(parts) + "/"

status, data = await session.post("/new-package", json={})
status, data = await session.post("new-package", json={})
if status != 200:
log.error(f"Server returned invalid status code {status}: {data}")
raise Exit
Expand All @@ -61,7 +61,7 @@ async def upload(session, version, name, description, url, license, files):
if license:
payload["license"] = license

status, data = await session.put(f"/new-package/{upload_token}", json=payload)
status, data = await session.put(f"new-package/{upload_token}", json=payload)
if status == 400:
show_validation_errors(data)
raise Exit
Expand All @@ -74,7 +74,7 @@ async def upload(session, version, name, description, url, license, files):
log.info(f"Uploading {filename} ...")
session.tus_upload(upload_token, fullpath, filename)

status, data = await session.post(f"/new-package/{upload_token}/publish", json={})
status, data = await session.post(f"new-package/{upload_token}/publish", json={})
if status == 400:
show_validation_errors(data)
raise Exit
Expand Down
6 changes: 3 additions & 3 deletions bananas_cli/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
class Session:
def __init__(self, api_url, tus_url):
self.session = None
self.api_url = api_url
self.tus_url = tus_url
self.api_url = f"${api_url}/"
self.tus_url = f"${tus_url}/"

self._headers = {}

Expand Down Expand Up @@ -54,7 +54,7 @@ async def put(self, url, json):
return await self._read_response(response)

def tus_upload(self, upload_token, fullpath, filename):
full_url = urllib.parse.urljoin(self.tus_url, "/new-package/tus/")
full_url = urllib.parse.urljoin(self.tus_url, "new-package/tus/")
tus = TusClient(full_url)

try:
Expand Down

0 comments on commit 96fa301

Please sign in to comment.