@kubb/plugin-axios 5.9.0 → 5.9.2

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.
@@ -150,12 +150,17 @@ function jsonReplacer(_key: string, value: unknown): unknown {
150
150
 
151
151
  function appendFormDataValue({ formData, key, value, contentType }: { formData: FormData; key: string; value: unknown; contentType?: string }): void {
152
152
  if (value === undefined || value === null) return
153
- if (value instanceof Blob) formData.append(key, value)
154
- else if (typeof value === 'object' && !(value instanceof Date)) {
153
+ if (value instanceof Blob) {
154
+ formData.append(key, value)
155
+ return
156
+ }
157
+ if (typeof value === 'object' && !(value instanceof Date)) {
155
158
  const json = JSON.stringify(value, jsonReplacer)
156
159
  // A part's media type can only be set by wrapping the value in a typed Blob.
157
160
  formData.append(key, contentType ? new Blob([json], { type: contentType }) : json)
158
- } else formData.append(key, toValue(value))
161
+ return
162
+ }
163
+ formData.append(key, toValue(value))
159
164
  }
160
165
 
161
166
  /**
@@ -179,8 +184,11 @@ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encod
179
184
  const formData = new FormData()
180
185
  for (const [key, value] of Object.entries(body as Record<string, unknown>)) {
181
186
  const partContentType = encoding?.[key]?.contentType
182
- if (Array.isArray(value)) for (const item of value) appendFormDataValue({ formData, key, value: item, contentType: partContentType })
183
- else appendFormDataValue({ formData, key, value, contentType: partContentType })
187
+ if (Array.isArray(value)) {
188
+ for (const item of value) appendFormDataValue({ formData, key, value: item, contentType: partContentType })
189
+ continue
190
+ }
191
+ appendFormDataValue({ formData, key, value, contentType: partContentType })
184
192
  }
185
193
  return formData
186
194
  }