bruce-models 1.7.7 → 1.7.8
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/bruce-models.umd.js
CHANGED
|
@@ -460,12 +460,18 @@
|
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
+
// TODO: Currently checks for CSV vs json specifically,
|
|
464
|
+
// Need to see if our api is generally good at setting content-type headers.
|
|
465
|
+
// Make it less specific to CSV.
|
|
463
466
|
function parseResult(data) {
|
|
464
467
|
return __awaiter(this, void 0, void 0, function* () {
|
|
465
468
|
if (data.status == 200) {
|
|
469
|
+
let type = data.headers.get("Content-Type");
|
|
470
|
+
if (type) {
|
|
471
|
+
type = type.trim().toLowerCase();
|
|
472
|
+
}
|
|
466
473
|
let encoding = "";
|
|
467
|
-
const
|
|
468
|
-
const charset = type ? type.split(";").find((x) => x.trim().toLowerCase().startsWith("charset=")) : "";
|
|
474
|
+
const charset = type ? type.split(";").find((x) => x.startsWith("charset=")) : "";
|
|
469
475
|
if (charset && charset.includes("=")) {
|
|
470
476
|
encoding = charset.split("=")[1];
|
|
471
477
|
encoding = encoding.toLowerCase();
|
|
@@ -479,11 +485,18 @@
|
|
|
479
485
|
if (!text || !text.trim()) {
|
|
480
486
|
return null;
|
|
481
487
|
}
|
|
488
|
+
if (type && type.includes("text/csv")) {
|
|
489
|
+
return text;
|
|
490
|
+
}
|
|
482
491
|
return JSON.parse(text);
|
|
483
492
|
}
|
|
484
493
|
else {
|
|
485
494
|
const buffer = yield data.arrayBuffer();
|
|
486
|
-
|
|
495
|
+
const text = new TextDecoder(encoding).decode(buffer);
|
|
496
|
+
if (type && type.includes("text/csv")) {
|
|
497
|
+
return text;
|
|
498
|
+
}
|
|
499
|
+
return JSON.parse(text);
|
|
487
500
|
}
|
|
488
501
|
}
|
|
489
502
|
else {
|