-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
No way to replace path without replacing query #111
Comments
Did you try |
I mean, that would work, but why even have the |
Honestly I don't want to blow up URL class with new methods. |
My need is in use for a web framework, which is why I'm interested in reducing the amount of unnecessary work implied by |
Thus do you need cutting first path symbols from relative URL? |
Then >>> URL('https://foo.tld/path?a=1#fragment').with_host('bar.tld')
URL('https://bar.tld/path?a=1#fragment')
>>> URL('https://foo.tld/path?a=1#fragment').with_path('/new/path')
URL('https://foo.tld/new/path') |
It is totally unexpected that |
Working with this library, and got this unexpected behaviour as well. The docs quite clearly say that
Is there any appetite for a PR? |
is this considered as a bug or by-design? |
It is a design decision. |
sounds good,maybe also fragment … |
Hi, I made some changes to support this behavior. Could you please take a look? Thank you! |
The following is unexpected behavior:
While I understand the design decision to treat the query and fragment components as part of the path, this has left us without an (efficient) way to preserve the query and fragment components when replacing just the path. The only way to do it is:
This is a total of 4 extra method calls, at least of which does a lot of unnecessary processing. I'm assuming that there's code out there that depends on this weird behavior, so I'd like to propose and, with permission, implement a new method,
with_just_path
, which replaces the path but leaves the fragment and query the same.The text was updated successfully, but these errors were encountered: