@veritree/services 2.66.0 → 2.67.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/package.json +1 -1
- package/src/utils/args.js +13 -5
package/package.json
CHANGED
package/src/utils/args.js
CHANGED
|
@@ -11,12 +11,18 @@ export const createParamsStringFromArgs = (args) => {
|
|
|
11
11
|
|
|
12
12
|
if (Array.isArray(value)) {
|
|
13
13
|
arr = value
|
|
14
|
+
.filter((item) => item !== undefined && item !== null && item !== "")
|
|
14
15
|
.map((item, index) => {
|
|
15
16
|
const param = `${key}[]=${encodeURIComponent(item)}`;
|
|
17
|
+
|
|
16
18
|
return index === 0 ? `${param}` : `&${param}`;
|
|
17
19
|
})
|
|
18
20
|
.join("");
|
|
19
21
|
|
|
22
|
+
if (!arr.length) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
paramsString.push(arr);
|
|
21
27
|
} else {
|
|
22
28
|
if (value !== undefined) {
|
|
@@ -27,17 +33,19 @@ export const createParamsStringFromArgs = (args) => {
|
|
|
27
33
|
* solution, we have this -x- to allow
|
|
28
34
|
* same keys to be passed. The args
|
|
29
35
|
* would look like:
|
|
30
|
-
*
|
|
31
|
-
* {
|
|
36
|
+
*
|
|
37
|
+
* {
|
|
32
38
|
* 'box-x-1': 1
|
|
33
39
|
* 'box-x-2': 2
|
|
34
40
|
* }
|
|
35
|
-
*
|
|
41
|
+
*
|
|
36
42
|
* and would be translated as expected:
|
|
37
|
-
*
|
|
43
|
+
*
|
|
38
44
|
* box=1&box=2
|
|
39
45
|
*/
|
|
40
|
-
paramsString.push(
|
|
46
|
+
paramsString.push(
|
|
47
|
+
`${key.split("-x-")[0]}=${encodeURIComponent(value)}`
|
|
48
|
+
);
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
});
|