@hapaul/api 0.1.32 → 0.1.34

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -112,14 +112,20 @@ function mergeHeaders(...allHeaders) {
112
112
  return finalHeaders;
113
113
  }
114
114
  function defaultQuerySerializer(query) {
115
- return new URLSearchParams(query).toString();
115
+ let str = "";
116
+ Object.entries(query).forEach(([key, val]) => {
117
+ if (Array.isArray(val)) str += `${key}=${val}`;
118
+ else if (isObject(val)) str += `${key}=${JSON.stringify(val)}`;
119
+ else str += `${key}=${val}`;
120
+ });
121
+ return str;
116
122
  }
117
123
  async function defaultBodySerializer(body, headers) {
118
124
  if (body instanceof FormData) return body;
119
125
  if (headers) {
120
126
  const contentType = headers.get("Content-Type");
121
127
  switch (contentType) {
122
- case "application/x-www-form-urlencoded": return new URLSearchParams(body).toString();
128
+ case "application/x-www-form-urlencoded": return defaultQuerySerializer(body);
123
129
  case "multipart/form-data": {
124
130
  headers.delete("Content-Type");
125
131
  const formData = new FormData();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hapaul/api",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [