@ciwergrp/nuxid 1.11.0 → 1.13.0

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
3
  "configKey": "nuxid",
4
- "version": "1.11.0",
4
+ "version": "1.13.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -14,6 +14,7 @@ export interface UseHttp<DefaultResponseType = any> {
14
14
  }
15
15
  export interface FormComposableOptions {
16
16
  alwaysFormData?: boolean;
17
+ multipartArrayBrackets?: boolean;
17
18
  fetcher?: typeof $fetch;
18
19
  fetchOptions?: NitroFetchOptions<NitroFetchRequest>;
19
20
  }
@@ -92,9 +92,13 @@ export default function useHttp(initialData, formOptions) {
92
92
  }
93
93
  if (value instanceof File) {
94
94
  formDataBody.append(key, value);
95
- } else if (Array.isArray(value) && value.every((item) => item instanceof File)) {
96
- value.forEach((file) => formDataBody.append(`${key}[]`, file));
95
+ } else if (Array.isArray(value) && value.length > 0 && value.every((item) => item instanceof File)) {
96
+ const fileArrayKey = formOptions?.multipartArrayBrackets === false ? key : `${key}[]`;
97
+ value.forEach((file) => formDataBody.append(fileArrayKey, file));
97
98
  } else if (Array.isArray(value)) {
99
+ if (value.length === 0) {
100
+ formDataBody.append(key, "[]");
101
+ }
98
102
  value.forEach((item, index) => {
99
103
  if (typeof item === "object" && item !== null && !(item instanceof File)) {
100
104
  Object.keys(item).forEach((subKey) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "All-in-one essential modules for Nuxt",
5
5
  "repository": {
6
6
  "type": "git",