Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Don't mutate passed URL object (#470)
Before this change, a passed URL object would be mutated if query parameters were appended via the `data` option. Now we clone the object instead, so the original is not affected. --- Background: I am passing `URL` objects to the `request` method, and then adding query parameters via the `data` option. Example: ```js import { request } from "urllib"; const url = new URL("http://example.com"); await request(url, { data: { param1: "value1" } }); ``` I found that if I then make another request to the same URL but with different parameters: ```js await request(url, { data: { param2: "value2" } }); ``` ...a request is actually made to `http://example.com?param1=value1¶m2=value2`. My URL object is being mutated by the urllib library. I see this as a bug.
- Loading branch information