api-def 0.14.2 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/Utils.js +11 -1
- package/esm/Utils.js +11 -1
- package/package.json +1 -1
package/cjs/Utils.js
CHANGED
|
@@ -105,6 +105,10 @@ const toFormDataValue = (value) => {
|
|
|
105
105
|
}
|
|
106
106
|
return String(value);
|
|
107
107
|
};
|
|
108
|
+
const getBlobFileName = (value) => {
|
|
109
|
+
const name = value.name;
|
|
110
|
+
return typeof name === "string" && name ? name : "blob";
|
|
111
|
+
};
|
|
108
112
|
const toFormData = (body) => {
|
|
109
113
|
if ((0, exports.isFormDataLike)(body)) {
|
|
110
114
|
return body;
|
|
@@ -132,7 +136,13 @@ const toFormData = (body) => {
|
|
|
132
136
|
}
|
|
133
137
|
return;
|
|
134
138
|
}
|
|
135
|
-
|
|
139
|
+
const formValue = toFormDataValue(value);
|
|
140
|
+
if (isBlob(formValue)) {
|
|
141
|
+
formData.append(key, formValue, getBlobFileName(formValue));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
formData.append(key, formValue);
|
|
145
|
+
}
|
|
136
146
|
};
|
|
137
147
|
for (const key of Object.keys(body)) {
|
|
138
148
|
appendValue(key, body[key]);
|
package/esm/Utils.js
CHANGED
|
@@ -94,6 +94,10 @@ const toFormDataValue = (value) => {
|
|
|
94
94
|
}
|
|
95
95
|
return String(value);
|
|
96
96
|
};
|
|
97
|
+
const getBlobFileName = (value) => {
|
|
98
|
+
const name = value.name;
|
|
99
|
+
return typeof name === "string" && name ? name : "blob";
|
|
100
|
+
};
|
|
97
101
|
export const toFormData = (body) => {
|
|
98
102
|
if (isFormDataLike(body)) {
|
|
99
103
|
return body;
|
|
@@ -121,7 +125,13 @@ export const toFormData = (body) => {
|
|
|
121
125
|
}
|
|
122
126
|
return;
|
|
123
127
|
}
|
|
124
|
-
|
|
128
|
+
const formValue = toFormDataValue(value);
|
|
129
|
+
if (isBlob(formValue)) {
|
|
130
|
+
formData.append(key, formValue, getBlobFileName(formValue));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
formData.append(key, formValue);
|
|
134
|
+
}
|
|
125
135
|
};
|
|
126
136
|
for (const key of Object.keys(body)) {
|
|
127
137
|
appendValue(key, body[key]);
|