MCPcopy Index your code
hub / github.com/wendux/fly / formatParams

Function formatParams

src/utils/utils.js:28–64  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

26 .replace(/%5D/gi, ']');
27 },
28 formatParams(data) {
29 let str = "";
30 let first = true;
31 let that = this;
32 if (!this.isObject(data)) {
33 return data;
34 }
35
36 function _encode(sub, path) {
37 let encode = that.encode;
38 let type = that.type(sub);
39 if (type == "array") {
40 sub.forEach(function (e, i) {
41 if (!that.isObject(e)) i = "";
42 _encode(e, path + `%5B${i}%5D`);
43 });
44
45 } else if (type == "object") {
46 for (let key in sub) {
47 if (path) {
48 _encode(sub[key], path + "%5B" + encode(key) + "%5D");
49 } else {
50 _encode(sub[key], encode(key));
51 }
52 }
53 } else {
54 if (!first) {
55 str += "&";
56 }
57 first = false;
58 str += path + "=" + encode(sub);
59 }
60 }
61
62 _encode(data, "");
63 return str;
64 },
65 // Do not overwrite existing attributes
66 merge(a, b) {
67 for (let key in b) {

Callers

nothing calls this directly

Calls 1

_encodeFunction · 0.70

Tested by

no test coverage detected