-
-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Description
The following is unexpected behavior:
url1 = URL("http://www.example.com/foo?bar=10")
url2 = url1.with_path("/bar")
assert url1.query = url2.query # Assertion fails
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:
url2 = url1.with_path(new_path).with_query(url1.query_string).with_fragment(url1.fragment)
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels