@koine/utils 1.0.68 → 1.0.71
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/buildUrlQueryString.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import isNull from "./isNull";
|
|
2
2
|
import isUndefined from "./isUndefined";
|
|
3
|
+
import isArray from "./isArray";
|
|
3
4
|
/**
|
|
4
5
|
* Get clean query string for URL
|
|
5
6
|
*
|
|
@@ -14,7 +15,12 @@ export function buildUrlQueryString(params) {
|
|
|
14
15
|
var output = "";
|
|
15
16
|
for (var key in params) {
|
|
16
17
|
var value = params[key];
|
|
17
|
-
if (
|
|
18
|
+
if (isArray(value)) {
|
|
19
|
+
for (var i = 0; i < value.length; i++) {
|
|
20
|
+
output += "".concat(key, "=").concat(encodeURIComponent(value[i] + ""), "&");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (!isNull(value) && !isUndefined(value)) {
|
|
18
24
|
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
19
25
|
}
|
|
20
26
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildUrlQueryString = void 0;
|
|
4
4
|
var isNull_1 = require("./isNull");
|
|
5
5
|
var isUndefined_1 = require("./isUndefined");
|
|
6
|
+
var isArray_1 = require("./isArray");
|
|
6
7
|
/**
|
|
7
8
|
* Get clean query string for URL
|
|
8
9
|
*
|
|
@@ -17,7 +18,12 @@ function buildUrlQueryString(params) {
|
|
|
17
18
|
var output = "";
|
|
18
19
|
for (var key in params) {
|
|
19
20
|
var value = params[key];
|
|
20
|
-
if (
|
|
21
|
+
if ((0, isArray_1.default)(value)) {
|
|
22
|
+
for (var i = 0; i < value.length; i++) {
|
|
23
|
+
output += "".concat(key, "=").concat(encodeURIComponent(value[i] + ""), "&");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (!(0, isNull_1.default)(value) && !(0, isUndefined_1.default)(value)) {
|
|
21
27
|
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
22
28
|
}
|
|
23
29
|
}
|