Skip to content

Commit ba8d118

Browse files
jbl428imdudu1
andcommitted
fix: replace form data to url search params
Co-authored-by: imdudu1 <cd80@kakao.com>
1 parent b90f508 commit ba8d118

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

lib/builders/payload.builder.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ export class PayloadBuilder {
1313
return { 'Content-Type': 'application/json' };
1414
}
1515

16-
if (this.requestFormBuilder != null) {
17-
return { 'Content-Type': 'application/x-www-form-urlencoded' };
18-
}
19-
2016
return undefined;
2117
}
2218

lib/builders/request-form.builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export class RequestFormBuilder {
1616
this.metadata.push([index, [key, defaultValue]]);
1717
}
1818

19-
build(args: any[]): FormData {
20-
const form = new FormData();
19+
build(args: any[]): URLSearchParams {
20+
const form = new URLSearchParams();
2121

2222
this.metadata.forEach(([index, [key, defaultValue]]) => {
2323
if (key != null) {

lib/supports/node-fetch.injector.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,10 @@ describe('NodeFetchInjector', () => {
311311

312312
// then
313313
expect(httpClient.requestInfo).toHaveLength(1);
314-
expect(await httpClient.requestInfo[0].text()).toContain(
315-
`Content-Disposition: form-data; name="foo"`,
316-
);
314+
const formData = await httpClient.requestInfo[0].formData();
315+
expect(formData.get('foo')).toBe('bar');
317316
expect(httpClient.requestInfo[0].headers.get('Content-Type')).toBe(
318-
'application/x-www-form-urlencoded',
317+
'application/x-www-form-urlencoded;charset=UTF-8',
319318
);
320319
});
321320

0 commit comments

Comments
 (0)