Commit 5ba77da
committed
Fix URL params to merge with existing query parameters instead of replacing them
When creating a URL with `URL(url, params=params)` or `Request(method, url, params=params)`,
the params now merge with existing query parameters in the URL instead of completely
replacing them. This makes the behavior consistent with the Python requests library.
Before:
URL("https://example.com?a=1", params={"b": "2"})
Result: "https://example.com?b=2" # 'a=1' was lost
After:
URL("https://example.com?a=1", params={"b": "2"})
Result: "https://example.com?a=1&b=2" # parameters merged
Special cases handled:
- Empty dict params={} preserves existing query parameters
- None params preserves existing query parameters
- QueryParams objects are used directly (for copy_* methods)
- Overlapping parameter names are overridden by new values
Fixes #6521 parent 4fb9528 commit 5ba77da
3 files changed
Lines changed: 31 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
115 | 141 | | |
116 | 142 | | |
117 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
| 162 | + | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
0 commit comments