@mercurjs/client 2.0.0-canary.25 → 2.0.0-canary.27

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.mjs +10 -4
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -106,16 +106,22 @@ function createClient(options) {
106
106
  const base = new URL(baseUrl);
107
107
  const fullPath = `${base.pathname.replace(/\/$/, "")}/${urlPath.replace(/^\//, "")}`;
108
108
  const url = new URL(fullPath, base.origin);
109
+ const isFormData = (inputFetchOptions == null ? void 0 : inputFetchOptions.body) instanceof FormData;
109
110
  let body;
110
- if (method === "GET" && Object.keys(rest).length > 0) {
111
+ if (isFormData) {
112
+ body = inputFetchOptions.body;
113
+ } else if (method === "GET" && Object.keys(rest).length > 0) {
111
114
  url.search = qs.stringify(rest, { skipNulls: true });
112
115
  } else if (method !== "GET" && Object.keys(rest).length > 0) {
113
116
  body = JSON.stringify(rest);
114
117
  }
115
- const headers = new Headers(__spreadValues(__spreadValues({
116
- "Content-Type": "application/json",
118
+ const defaultHeaders = {
117
119
  Accept: "application/json"
118
- }, defaultFetchOptions == null ? void 0 : defaultFetchOptions.headers), inputFetchOptions == null ? void 0 : inputFetchOptions.headers));
120
+ };
121
+ if (!isFormData) {
122
+ defaultHeaders["Content-Type"] = "application/json";
123
+ }
124
+ const headers = new Headers(__spreadValues(__spreadValues(__spreadValues({}, defaultHeaders), defaultFetchOptions == null ? void 0 : defaultFetchOptions.headers), inputFetchOptions == null ? void 0 : inputFetchOptions.headers));
119
125
  return fetch(url, __spreadProps(__spreadValues(__spreadValues({}, defaultFetchOptions), inputFetchOptions), {
120
126
  method,
121
127
  body,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/client",
3
- "version": "2.0.0-canary.25",
3
+ "version": "2.0.0-canary.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",