@taybart/corvid 0.1.28 → 0.1.29

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/index.js CHANGED
@@ -549,7 +549,7 @@ class request {
549
549
  ...this.opts.headers,
550
550
  ...override.headers
551
551
  },
552
- body: JSON.stringify(body)
552
+ body: body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer ? body : JSON.stringify(body)
553
553
  }
554
554
  };
555
555
  }
@@ -579,8 +579,10 @@ class request {
579
579
  body
580
580
  };
581
581
  }
582
- this.log.debug(`content type: ${res.headers.get('content-type')}`);
583
- if ('application/json' === res.headers.get('content-type')) return await res.json();
582
+ const ct = res.headers.get('content-type') ?? '';
583
+ this.log.debug(`content type: ${ct}`);
584
+ if (ct.includes('application/json')) return await res.json();
585
+ if (ct.startsWith('image/') || 'application/octet-stream' === ct) return await res.blob();
584
586
  return await res.text();
585
587
  }
586
588
  constructor(opts = {}, verbose = false){
package/dist/network.d.ts CHANGED
@@ -64,7 +64,7 @@ export declare class request {
64
64
  isPrototypeOf(v: Object): boolean;
65
65
  propertyIsEnumerable(v: PropertyKey): boolean;
66
66
  };
67
- body: string;
67
+ body: string | ArrayBuffer | FormData | Blob;
68
68
  };
69
69
  };
70
70
  do({ path, params: passedParams, override, _recurselevel, }?: {
package/dist/network.js CHANGED
@@ -124,7 +124,7 @@ class request {
124
124
  ...this.opts.headers,
125
125
  ...override.headers
126
126
  },
127
- body: JSON.stringify(body)
127
+ body: body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer ? body : JSON.stringify(body)
128
128
  }
129
129
  };
130
130
  }
@@ -154,8 +154,10 @@ class request {
154
154
  body
155
155
  };
156
156
  }
157
- this.log.debug(`content type: ${res.headers.get('content-type')}`);
158
- if ('application/json' === res.headers.get('content-type')) return await res.json();
157
+ const ct = res.headers.get('content-type') ?? '';
158
+ this.log.debug(`content type: ${ct}`);
159
+ if (ct.includes('application/json')) return await res.json();
160
+ if (ct.startsWith('image/') || 'application/octet-stream' === ct) return await res.blob();
159
161
  return await res.text();
160
162
  }
161
163
  constructor(opts = {}, verbose = false){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taybart/corvid",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {