api-def 0.6.2-alpha.3 → 0.6.2-alpha.5

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.
@@ -127,17 +127,18 @@ var RequestContext = /** @class */ (function () {
127
127
  return this;
128
128
  };
129
129
  RequestContext.prototype.parseRequestBody = function () {
130
+ var _a;
130
131
  if (this.computedConfig.body && this.computedConfig.headers) {
131
132
  var contentTypeKey = Object.keys(this.computedConfig.headers).find(function (key) { return key.toLowerCase() === "content-type"; });
132
- var contentType = contentTypeKey && this.computedConfig.headers[contentTypeKey];
133
- if (typeof contentType === "string" && contentType.toLowerCase() === "multipart/form-data") {
133
+ var contentType = contentTypeKey && ((_a = this.computedConfig.headers[contentTypeKey]) === null || _a === void 0 ? void 0 : _a.toString());
134
+ if (contentType === "application/x-www-form-urlencoded") {
134
135
  var searchParams = new url_1.URLSearchParams();
135
- for (var _i = 0, _a = Object.keys(this.computedConfig.body); _i < _a.length; _i++) {
136
- var key = _a[_i];
136
+ for (var _i = 0, _b = Object.keys(this.computedConfig.body); _i < _b.length; _i++) {
137
+ var key = _b[_i];
137
138
  var value = this.computedConfig.body[key];
138
- searchParams.set(key, value === null || value === void 0 ? void 0 : value.toString());
139
+ searchParams.append(key, value === null || value === void 0 ? void 0 : value.toString());
139
140
  }
140
- this.parsedBody = searchParams.toString();
141
+ this.parsedBody = searchParams;
141
142
  }
142
143
  else {
143
144
  this.parsedBody = this.computedConfig.body;
@@ -14,6 +14,7 @@ var isRequestError = function (error) {
14
14
  exports.isRequestError = isRequestError;
15
15
  var convertToRequestError = function (config) {
16
16
  var error = config.error, context = config.context, response = config.response, code = config.code;
17
+ var body = context.getParsedBody();
17
18
  var resultError = Object.assign(error, {
18
19
  name: "RequestError",
19
20
  response: response,
@@ -23,7 +24,7 @@ var convertToRequestError = function (config) {
23
24
  url: context.getRequestUrl().href,
24
25
  query: context.computedConfig.query,
25
26
  headers: context.computedConfig.headers,
26
- body: context.getParsedBody(),
27
+ body: body,
27
28
  },
28
29
  });
29
30
  delete resultError.config;
@@ -125,17 +125,18 @@ var RequestContext = /** @class */ (function () {
125
125
  return this;
126
126
  };
127
127
  RequestContext.prototype.parseRequestBody = function () {
128
+ var _a;
128
129
  if (this.computedConfig.body && this.computedConfig.headers) {
129
130
  var contentTypeKey = Object.keys(this.computedConfig.headers).find(function (key) { return key.toLowerCase() === "content-type"; });
130
- var contentType = contentTypeKey && this.computedConfig.headers[contentTypeKey];
131
- if (typeof contentType === "string" && contentType.toLowerCase() === "multipart/form-data") {
131
+ var contentType = contentTypeKey && ((_a = this.computedConfig.headers[contentTypeKey]) === null || _a === void 0 ? void 0 : _a.toString());
132
+ if (contentType === "application/x-www-form-urlencoded") {
132
133
  var searchParams = new URLSearchParams();
133
- for (var _i = 0, _a = Object.keys(this.computedConfig.body); _i < _a.length; _i++) {
134
- var key = _a[_i];
134
+ for (var _i = 0, _b = Object.keys(this.computedConfig.body); _i < _b.length; _i++) {
135
+ var key = _b[_i];
135
136
  var value = this.computedConfig.body[key];
136
- searchParams.set(key, value === null || value === void 0 ? void 0 : value.toString());
137
+ searchParams.append(key, value === null || value === void 0 ? void 0 : value.toString());
137
138
  }
138
- this.parsedBody = searchParams.toString();
139
+ this.parsedBody = searchParams;
139
140
  }
140
141
  else {
141
142
  this.parsedBody = this.computedConfig.body;
@@ -10,6 +10,7 @@ export var isRequestError = function (error) {
10
10
  };
11
11
  export var convertToRequestError = function (config) {
12
12
  var error = config.error, context = config.context, response = config.response, code = config.code;
13
+ var body = context.getParsedBody();
13
14
  var resultError = Object.assign(error, {
14
15
  name: "RequestError",
15
16
  response: response,
@@ -19,7 +20,7 @@ export var convertToRequestError = function (config) {
19
20
  url: context.getRequestUrl().href,
20
21
  query: context.computedConfig.query,
21
22
  headers: context.computedConfig.headers,
22
- body: context.getParsedBody(),
23
+ body: body,
23
24
  },
24
25
  });
25
26
  delete resultError.config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "api-def",
3
- "version": "0.6.2-alpha.3",
3
+ "version": "0.6.2-alpha.5",
4
4
  "description": "Typed API definitions with middleware support",
5
5
  "main": "cjs/index.js",
6
6
  "types": "esm/index.d.ts",