@trycourier/courier 4.0.0 → 4.0.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.
@@ -93,7 +93,7 @@ exports.initHttpClient = function (_a) {
93
93
  case 0:
94
94
  searchParams = String(new URLSearchParams(config === null || config === void 0 ? void 0 : config.params));
95
95
  searchQueryString = searchParams && "?" + searchParams;
96
- fullUrl = String(new URL("" + url + searchQueryString, baseUrl));
96
+ fullUrl = encodeURI("" + (baseUrl !== null && baseUrl !== void 0 ? baseUrl : '') + url + searchQueryString);
97
97
  contentTypeHeader = body == null ? null : { "Content-Type": "application/json" };
98
98
  idempotencyKeyHeader = (config === null || config === void 0 ? void 0 : config.idempotencyKey) ? { "Idempotency-Key": config.idempotencyKey }
99
99
  : null;
@@ -107,12 +107,13 @@ exports.initHttpClient = function (_a) {
107
107
  })];
108
108
  case 1:
109
109
  response = _b.sent();
110
- parseAsJson = response.headers.get("content-type") === "application/json";
110
+ parseAsJson = response.headers.get("content-length") !== "0" &&
111
+ response.headers.get("content-type") === "application/json";
111
112
  return [4 /*yield*/, (parseAsJson ? response.json() : response.text())];
112
113
  case 2:
113
114
  data = _b.sent();
114
115
  if (!response.ok) {
115
- throw new CourierHttpClientError(data.message || "Un unexpected error has occurred", { response: response, data: data });
116
+ throw new CourierHttpClientError(data.message || "An unexpected error has occurred", { response: response, data: data });
116
117
  }
117
118
  return [2 /*return*/, { data: data }];
118
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/courier",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "A node.js module for communicating with the Courier REST API.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",