@modern-js/create-request 2.25.1 → 2.25.2

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.
@@ -23,7 +23,14 @@ const _querystring = /* @__PURE__ */ _interop_require_default._(require("query-s
23
23
  const _handleRes = require("./handleRes");
24
24
  let realRequest;
25
25
  let realAllowedHeaders;
26
- const originFetch = (...params) => fetch(...params).then(_handleRes.handleRes);
26
+ const originFetch = (...params) => {
27
+ var _init_method;
28
+ const [url, init] = params;
29
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
30
+ init.body = void 0;
31
+ }
32
+ return fetch(url, init).then(_handleRes.handleRes);
33
+ };
27
34
  const configure = (options) => {
28
35
  const { request, interceptor, allowedHeaders } = options;
29
36
  realRequest = request || originFetch;
@@ -81,8 +88,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
81
88
  body = payload.formData;
82
89
  } else if (payload.formUrlencoded) {
83
90
  headers["Content-Type"] = "application/x-www-form-urlencoded";
84
- if (typeof payload.formUrlencoded === "object" && // eslint-disable-next-line @typescript-eslint/ban-ts-comment
85
- // @ts-expect-error
91
+ if (typeof payload.formUrlencoded === "object" && // @ts-expect-error
86
92
  // eslint-disable-next-line node/prefer-global/url-search-params,node/no-unsupported-features/node-builtins
87
93
  !(payload.formUrlencoded instanceof URLSearchParams)) {
88
94
  body = _querystring.default.stringify(payload.formUrlencoded);
@@ -91,9 +97,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
91
97
  }
92
98
  }
93
99
  }
94
- if (method.toLowerCase() === "get") {
95
- body = void 0;
96
- }
97
100
  headers.accept = `application/json,*/*;q=0.8`;
98
101
  return fetcher(finalURL, {
99
102
  method,
package/dist/cjs/node.js CHANGED
@@ -25,7 +25,14 @@ const _querystring = /* @__PURE__ */ _interop_require_default._(require("query-s
25
25
  const _handleRes = require("./handleRes");
26
26
  let realRequest;
27
27
  let realAllowedHeaders = [];
28
- const originFetch = (...params) => (0, _nodefetch.default)(...params).then(_handleRes.handleRes);
28
+ const originFetch = (...params) => {
29
+ var _init_method;
30
+ const [, init] = params;
31
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
32
+ init.body = void 0;
33
+ }
34
+ return (0, _nodefetch.default)(...params).then(_handleRes.handleRes);
35
+ };
29
36
  const configure = (options) => {
30
37
  const { request, interceptor, allowedHeaders } = options;
31
38
  realRequest = request || originFetch;
@@ -93,9 +100,6 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
93
100
  }
94
101
  url = `http://localhost:${port}${finalPath}`;
95
102
  }
96
- if (method.toLowerCase() === "get") {
97
- body = void 0;
98
- }
99
103
  const fetcher = realRequest || originFetch;
100
104
  if (method.toLowerCase() === "get") {
101
105
  body = void 0;
@@ -1,6 +1,6 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
3
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
5
  import { compile, pathToRegexp } from "path-to-regexp";
6
6
  import qs from "query-string";
@@ -11,7 +11,12 @@ var originFetch = function() {
11
11
  for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
12
12
  params[_key] = arguments[_key];
13
13
  }
14
- return fetch.apply(void 0, _to_consumable_array(params)).then(handleRes);
14
+ var _init_method;
15
+ var _params = _sliced_to_array(params, 2), url = _params[0], init = _params[1];
16
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
17
+ init.body = void 0;
18
+ }
19
+ return fetch(url, init).then(handleRes);
15
20
  };
16
21
  export var configure = function(options) {
17
22
  var request = options.request, interceptor = options.interceptor, allowedHeaders = options.allowedHeaders;
@@ -75,8 +80,7 @@ export var createRequest = function(path, method, port) {
75
80
  body = payload.formData;
76
81
  } else if (payload.formUrlencoded) {
77
82
  headers["Content-Type"] = "application/x-www-form-urlencoded";
78
- if (typeof payload.formUrlencoded === "object" && // eslint-disable-next-line @typescript-eslint/ban-ts-comment
79
- // @ts-expect-error
83
+ if (typeof payload.formUrlencoded === "object" && // @ts-expect-error
80
84
  // eslint-disable-next-line node/prefer-global/url-search-params,node/no-unsupported-features/node-builtins
81
85
  !_instanceof(payload.formUrlencoded, URLSearchParams)) {
82
86
  body = qs.stringify(payload.formUrlencoded);
@@ -85,9 +89,6 @@ export var createRequest = function(path, method, port) {
85
89
  }
86
90
  }
87
91
  }
88
- if (method.toLowerCase() === "get") {
89
- body = void 0;
90
- }
91
92
  headers.accept = "application/json,*/*;q=0.8";
92
93
  return [
93
94
  2,
package/dist/esm/node.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
1
2
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
2
3
  import nodeFetch from "node-fetch";
3
4
  import { compile, pathToRegexp } from "path-to-regexp";
@@ -10,6 +11,11 @@ var originFetch = function() {
10
11
  for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
11
12
  params[_key] = arguments[_key];
12
13
  }
14
+ var _init_method;
15
+ var _params = _sliced_to_array(params, 2), init = _params[1];
16
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
17
+ init.body = void 0;
18
+ }
13
19
  return nodeFetch.apply(void 0, _to_consumable_array(params)).then(handleRes);
14
20
  };
15
21
  export var configure = function(options) {
@@ -100,9 +106,6 @@ export var createRequest = function(path, method, port) {
100
106
  }
101
107
  url = "http://localhost:".concat(port).concat(finalPath);
102
108
  }
103
- if (method.toLowerCase() === "get") {
104
- body = void 0;
105
- }
106
109
  var fetcher = realRequest || originFetch;
107
110
  if (method.toLowerCase() === "get") {
108
111
  body = void 0;
@@ -3,7 +3,14 @@ import qs from "query-string";
3
3
  import { handleRes } from "./handleRes";
4
4
  let realRequest;
5
5
  let realAllowedHeaders;
6
- const originFetch = (...params) => fetch(...params).then(handleRes);
6
+ const originFetch = (...params) => {
7
+ var _init_method;
8
+ const [url, init] = params;
9
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
10
+ init.body = void 0;
11
+ }
12
+ return fetch(url, init).then(handleRes);
13
+ };
7
14
  export const configure = (options) => {
8
15
  const { request, interceptor, allowedHeaders } = options;
9
16
  realRequest = request || originFetch;
@@ -61,8 +68,7 @@ export const createRequest = (path, method, port, httpMethodDecider = "functionN
61
68
  body = payload.formData;
62
69
  } else if (payload.formUrlencoded) {
63
70
  headers["Content-Type"] = "application/x-www-form-urlencoded";
64
- if (typeof payload.formUrlencoded === "object" && // eslint-disable-next-line @typescript-eslint/ban-ts-comment
65
- // @ts-expect-error
71
+ if (typeof payload.formUrlencoded === "object" && // @ts-expect-error
66
72
  // eslint-disable-next-line node/prefer-global/url-search-params,node/no-unsupported-features/node-builtins
67
73
  !(payload.formUrlencoded instanceof URLSearchParams)) {
68
74
  body = qs.stringify(payload.formUrlencoded);
@@ -71,9 +77,6 @@ export const createRequest = (path, method, port, httpMethodDecider = "functionN
71
77
  }
72
78
  }
73
79
  }
74
- if (method.toLowerCase() === "get") {
75
- body = void 0;
76
- }
77
80
  headers.accept = `application/json,*/*;q=0.8`;
78
81
  return fetcher(finalURL, {
79
82
  method,
@@ -5,7 +5,14 @@ import qs from "query-string";
5
5
  import { handleRes } from "./handleRes";
6
6
  let realRequest;
7
7
  let realAllowedHeaders = [];
8
- const originFetch = (...params) => nodeFetch(...params).then(handleRes);
8
+ const originFetch = (...params) => {
9
+ var _init_method;
10
+ const [, init] = params;
11
+ if ((init === null || init === void 0 ? void 0 : (_init_method = init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
12
+ init.body = void 0;
13
+ }
14
+ return nodeFetch(...params).then(handleRes);
15
+ };
9
16
  export const configure = (options) => {
10
17
  const { request, interceptor, allowedHeaders } = options;
11
18
  realRequest = request || originFetch;
@@ -73,9 +80,6 @@ export const createRequest = (path, method, port, httpMethodDecider = "functionN
73
80
  }
74
81
  url = `http://localhost:${port}${finalPath}`;
75
82
  }
76
- if (method.toLowerCase() === "get") {
77
- body = void 0;
78
- }
79
83
  const fetcher = realRequest || originFetch;
80
84
  if (method.toLowerCase() === "get") {
81
85
  body = void 0;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.25.1",
18
+ "version": "2.25.2",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -64,7 +64,7 @@
64
64
  "path-to-regexp": "^6.2.0",
65
65
  "query-string": "^7.1.1",
66
66
  "@swc/helpers": "0.5.1",
67
- "@modern-js/utils": "2.25.1"
67
+ "@modern-js/utils": "2.25.2"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/jest": "^29",
@@ -74,9 +74,9 @@
74
74
  "jest": "^29",
75
75
  "nock": "^13.2.1",
76
76
  "typescript": "^5",
77
- "@modern-js/types": "2.25.1",
78
- "@scripts/jest-config": "2.25.1",
79
- "@scripts/build": "2.25.1"
77
+ "@modern-js/types": "2.25.2",
78
+ "@scripts/build": "2.25.2",
79
+ "@scripts/jest-config": "2.25.2"
80
80
  },
81
81
  "sideEffects": false,
82
82
  "publishConfig": {