Skip to content

Commit

Permalink
Less clever
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Nov 28, 2024
1 parent f97c2f1 commit eaad89c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/rest/client/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,19 @@


def get_relative_uri_from_absolute_uri(absolute_uri: str) -> str:
"""
Peels off the path and query string from an absolute URI. Useful when interacting
with `make_request(...)` util function which expects a relative path instead of a
full URI.
"""
parsed_uri = urllib.parse.urlparse(absolute_uri)
# Sanity check that we're working with an absolute URI
assert parsed_uri.scheme == "http" or parsed_uri.scheme == "https"
relative_uri = "?".join(filter(None, [parsed_uri.path, parsed_uri.query]))

relative_uri = parsed_uri.path
if parsed_uri.query:
relative_uri += "?" + parsed_uri.query

return relative_uri


Expand Down

0 comments on commit eaad89c

Please sign in to comment.