Skip to content

Commit 63facbe

Browse files
authored
Merge pull request #680 from dolevl/master
Checking if instanceof FormData before creating one
2 parents 076070e + 0ef9e33 commit 63facbe

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

templates/base/http-clients/axios-http-client.ejs

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export class HttpClient<SecurityDataType = unknown> {
7979
}
8080

8181
protected createFormData(input: Record<string, unknown>): FormData {
82+
if (input instanceof FormData) {
83+
return input;
84+
}
8285
return Object.keys(input || {}).reduce((formData, key) => {
8386
const property = input[key];
8487
const propertyContent: any[] = (property instanceof Array) ? property : [property]

tests/spec/axios/__snapshots__/basic.test.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,9 @@ export class HttpClient<SecurityDataType = unknown> {
19891989
}
19901990

19911991
protected createFormData(input: Record<string, unknown>): FormData {
1992+
if (input instanceof FormData) {
1993+
return input;
1994+
}
19921995
return Object.keys(input || {}).reduce((formData, key) => {
19931996
const property = input[key];
19941997
const propertyContent: any[] = property instanceof Array ? property : [property];

tests/spec/axiosSingleHttpClient/__snapshots__/basic.test.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,9 @@ export class HttpClient<SecurityDataType = unknown> {
19891989
}
19901990

19911991
protected createFormData(input: Record<string, unknown>): FormData {
1992+
if (input instanceof FormData) {
1993+
return input;
1994+
}
19921995
return Object.keys(input || {}).reduce((formData, key) => {
19931996
const property = input[key];
19941997
const propertyContent: any[] = property instanceof Array ? property : [property];

tests/spec/js/__snapshots__/basic.test.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export class HttpClient {
5656
}
5757
}
5858
createFormData(input) {
59+
if (input instanceof FormData) {
60+
return input;
61+
}
5962
return Object.keys(input || {}).reduce((formData, key) => {
6063
const property = input[key];
6164
const propertyContent = property instanceof Array ? property : [property];

0 commit comments

Comments
 (0)