@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 CHANGED
@@ -1,5 +1,4 @@
1
1
  import { PromiseProgress } from './promise-progress';
2
-
3
2
  /**
4
3
  * Download blob as a file
5
4
  *
package/dist/http.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { PromiseProgress } from './promise-progress';
2
-
3
2
  export type DecodedResponse<T> = Response & {
4
3
  data: T | null;
5
4
  };
package/dist/index.cjs CHANGED
@@ -1209,7 +1209,12 @@ ${opts.message || this.desc}`;
1209
1209
  }
1210
1210
  class HttpResponse extends Response {
1211
1211
  constructor(resp, stream) {
1212
- super(stream, { headers: resp.headers, status: resp.status, statusText: resp.statusText });
1212
+ const body = [204, 205, 304].includes(resp.status) ? null : stream;
1213
+ super(body, {
1214
+ headers: resp.headers,
1215
+ status: resp.status,
1216
+ statusText: resp.statusText
1217
+ });
1213
1218
  __publicField(this, "data");
1214
1219
  __publicField(this, "ok");
1215
1220
  __publicField(this, "redirected");
@@ -1249,8 +1254,9 @@ ${opts.message || this.desc}`;
1249
1254
  request(opts = {}) {
1250
1255
  var _a;
1251
1256
  if (!this.url && !opts.url) throw new Error("URL needs to be set");
1252
- let url = (((_a = opts.url) == null ? void 0 : _a.startsWith("http")) ? opts.url : (this.url || "") + (opts.url || "")).replace(/([^:]\/)\/+/g, "$1");
1253
- if (opts.fragment) url.includes("#") ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : url += "#" + opts.fragment;
1257
+ let url = ((_a = opts.url) == null ? void 0 : _a.startsWith("http")) ? opts.url : (this.url || "") + (opts.url || "");
1258
+ url = url.replaceAll(/([^:]\/)\/+/g, "$1");
1259
+ if (opts.fragment) url.includes("#") ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : `${url}#${opts.fragment}`;
1254
1260
  if (opts.query) {
1255
1261
  const q = Array.isArray(opts.query) ? opts.query : Object.keys(opts.query).map((k) => ({ key: k, value: opts.query[k] }));
1256
1262
  url += (url.includes("?") ? "&" : "?") + q.map((q2) => `${q2.key}=${q2.value}`).join("&");