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

Function _encode

src/utils/utils.js:36–60  ·  view source on GitHub ↗
(sub, path)

Source from the content-addressed store, hash-verified

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;

Callers 1

formatParamsFunction · 0.70

Calls 1

encodeFunction · 0.85

Tested by

no test coverage detected