Skip to content

Commit 836feb4

Browse files
authored
Remove unnecessary double Request wrapping in searchParams handling (#773)
1 parent 84ff3b9 commit 836feb4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source/core/Ky.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ export class Ky {
248248
const searchParams = '?' + textSearchParams;
249249
const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
250250

251-
// The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.
252-
this.request = new globalThis.Request(new globalThis.Request(url, {...this.request}), this.#options as RequestInit);
251+
// Recreate request with the updated URL. We already have all options in this.#options, including duplex.
252+
this.request = new globalThis.Request(url, this.#options as RequestInit);
253253
}
254254

255255
// If `onUploadProgress` is passed, it uses the stream API internally

0 commit comments

Comments
 (0)