Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some cases of merging with base_url #1532

Merged
merged 3 commits into from Mar 24, 2021
Merged

Fix some cases of merging with base_url #1532

merged 3 commits into from Mar 24, 2021

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Mar 23, 2021

Use a more resilient implementation for merging against a base_url.

Prevents the merge URL from being treated as absolute in some cases.

Eg, previously...

>>> client = httpx.Client(base_url="https://example.org/some/path")
>>> client.build_request("GET", "/sub:path")
<Request('GET', 'sub:path')>

Is now fixed...

>>> client = httpx.Client(base_url="https://example.org/some/path")
>>> client.build_request("GET", "/sub:path")
<Request('GET', 'https://example.org/some/path/sub:path')>

Also now deals more correctly with joining relative URLs, eg...

httpx.URL("/path/to/somewhere/").join("../somewhere-else")
URL('/path/to/somewhere-else')

Closes #1498

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nice. Worth adding a test case with that special path containing : in #1498?

@tomchristie
Copy link
Member Author

Yup, got one for that... test_merge_relative_url_with_path_including_colon

@tomchristie tomchristie merged commit 6cb1672 into master Mar 24, 2021
@tomchristie tomchristie deleted the fix-merge-url branch March 24, 2021 10:51
@tomchristie tomchristie mentioned this pull request Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug with merging base_url with relative path if colon present in path
2 participants