Messing around with http decoding
All checks were successful
Build / Build NPM Project (push) Successful in 24s
Build / Tag Version (push) Successful in 7s

This commit is contained in:
Zakary Timson 2024-08-13 15:41:47 -04:00
parent d587b92ea4
commit 535fc0271e
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.14.10", "version": "0.14.11",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@ -105,12 +105,12 @@ export class Http {
}); });
resp.data = new Response(stream); resp.data = new Response(stream);
if(opts.decode !== false) { if(opts.decode == null || opts.decode) {
const content = resp.headers.get('Content-Type')?.toLowerCase(); const content = resp.headers.get('Content-Type')?.toLowerCase();
if(content?.includes('application')) resp.data = <T>await resp.data.blob(); if(content?.includes('form')) resp.data = <T>await resp.data.formData();
else if(content?.includes('form')) resp.data = <T>await resp.data.formData();
else if(content?.includes('json')) resp.data = <T>await resp.data.json(); else if(content?.includes('json')) resp.data = <T>await resp.data.json();
else if(content?.includes('text')) resp.data = <T>await resp.data.text(); else if(content?.includes('text')) resp.data = <T>await resp.data.text();
else if(content?.includes('application')) resp.data = <T>await resp.data.blob();
} }
if(resp.ok) res(resp); if(resp.ok) res(resp);