Skip to content

Commit ac746e8

Browse files
committed
fix: fix root cause of clone issue
chore: revert #5 The issue was strings were being fed through the Uint8Array stream instead of being encoded.
1 parent 960a10d commit ac746e8

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

packages/fetch/src/body.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,7 @@ class AsyncIterablePump {
449449
controller.close();
450450
break;
451451
} else {
452-
if (typeof next.value === 'string') {
453-
controller.enqueue(new TextEncoder().encode(next.value));
454-
} else {
455-
controller.enqueue(next.value);
456-
}
452+
controller.enqueue(next.value);
457453
}
458454
}
459455
} catch (error) {

packages/fetch/src/utils/form-data.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@ export const getBoundary = () => randomBytes(8).toString('hex');
4444
* @param {string} boundary
4545
*/
4646
export async function * formDataIterator(form, boundary) {
47+
const encoder = new TextEncoder();
4748
for (const [name, value] of form) {
48-
yield getHeader(boundary, name, value);
49+
yield encoder.encode(getHeader(boundary, name, value));
4950

5051
if (isBlob(value)) {
5152
// @ts-ignore - we know our streams implement aysnc iteration
5253
yield * value.stream();
5354
} else {
54-
yield value;
55+
yield encoder.encode(value);
5556
}
5657

57-
yield carriage;
58+
yield encoder.encode(carriage);
5859
}
5960

60-
yield getFooter(boundary);
61+
yield encoder.encode(getFooter(boundary));
6162
}
6263

6364
/**

0 commit comments

Comments
 (0)