@ztimson/utils 0.23.20 → 0.23.22
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.
- package/dist/files.d.ts +0 -1
- package/dist/http.d.ts +0 -1
- package/dist/index.cjs +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +9 -3
- package/dist/index.mjs.map +1 -1
- package/dist/logger.d.ts +0 -1
- package/dist/misc.d.ts +0 -1
- package/dist/path-events.d.ts +0 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1205,7 +1205,12 @@ function errorFromCode(code, message) {
|
|
|
1205
1205
|
}
|
|
1206
1206
|
class HttpResponse extends Response {
|
|
1207
1207
|
constructor(resp, stream) {
|
|
1208
|
-
|
|
1208
|
+
const body = [204, 205, 304].includes(resp.status) ? null : stream;
|
|
1209
|
+
super(body, {
|
|
1210
|
+
headers: resp.headers,
|
|
1211
|
+
status: resp.status,
|
|
1212
|
+
statusText: resp.statusText
|
|
1213
|
+
});
|
|
1209
1214
|
__publicField(this, "data");
|
|
1210
1215
|
__publicField(this, "ok");
|
|
1211
1216
|
__publicField(this, "redirected");
|
|
@@ -1245,8 +1250,9 @@ const _Http = class _Http {
|
|
|
1245
1250
|
request(opts = {}) {
|
|
1246
1251
|
var _a;
|
|
1247
1252
|
if (!this.url && !opts.url) throw new Error("URL needs to be set");
|
|
1248
|
-
let url = ((
|
|
1249
|
-
|
|
1253
|
+
let url = ((_a = opts.url) == null ? void 0 : _a.startsWith("http")) ? opts.url : (this.url || "") + (opts.url || "");
|
|
1254
|
+
url = url.replaceAll(/([^:]\/)\/+/g, "$1");
|
|
1255
|
+
if (opts.fragment) url.includes("#") ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : `${url}#${opts.fragment}`;
|
|
1250
1256
|
if (opts.query) {
|
|
1251
1257
|
const q = Array.isArray(opts.query) ? opts.query : Object.keys(opts.query).map((k) => ({ key: k, value: opts.query[k] }));
|
|
1252
1258
|
url += (url.includes("?") ? "&" : "?") + q.map((q2) => `${q2.key}=${q2.value}`).join("&");
|