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

Base URL improvements #1130

Merged
merged 8 commits into from
Aug 5, 2020
Merged

Base URL improvements #1130

merged 8 commits into from
Aug 5, 2020

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Aug 5, 2020

  • Support no-argument invocation of httpx.URL().
  • Support client.base_url = ... as a property.
  • Resolve base_url joining behaviour.

So, an alternative implementation that closes #846, prompted by work in #1117.

The implementation here handles this by...

  • Always ensuring that base_url includes a trailing slash on the path. Eg. https://www.example.com/subpath/.
  • Always stripping any leading / when joining relative URLs.

This ends up given the behaviours you'd naturally expect from base_url usage, and also supports dotted paths, eg ../foo/bar

@tomchristie tomchristie added bug Something isn't working enhancement New feature or request labels Aug 5, 2020
@tomchristie tomchristie added this to the v0.14 milestone Aug 5, 2020
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.

The new dotted path support is really neat!

@florimondmanca
Copy link
Member

@tomchristie Should we pull the docs added in #1117 here as well?

@tomchristie
Copy link
Member Author

Yes, but I'm not 100% about the wording. Also I figure this is a bugfix either way, so let's get it in, and treat extra docs here as a nice-to-have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

base_url strips relative path
3 participants