@scalar/api-client
Version:
the open source API testing client
23 lines (22 loc) • 1.09 kB
JavaScript
import { extractFilename as v } from "../libs/extractAttachmentFilename.js";
import { computed as r, isRef as i } from "vue";
import m from "whatwg-mimetype";
function b(t) {
const l = (a) => a instanceof Blob, e = r(() => i(t.data) ? t.data.value : t.data), c = r(() => i(t.headers) ? t.headers.value : t.headers), o = r(() => {
var n;
const a = ((n = c.value.find((u) => u.name.toLowerCase() === "content-type")) == null ? void 0 : n.value) ?? "";
return new m(a);
}), s = r(() => {
var n;
const a = ((n = c.value.find((u) => u.name.toLowerCase() === "content-disposition")) == null ? void 0 : n.value) ?? "";
return v(a);
}), f = r(() => l(e.value) ? URL.createObjectURL(e.value) : typeof e.value == "string" ? URL.createObjectURL(new Blob([e.value], { type: o.value.toString() })) : e.value instanceof Object && Object.keys(e.value).length ? URL.createObjectURL(
new Blob([JSON.stringify(e.value)], {
type: o.value.toString()
})
) : "");
return { mimeType: o, attachmentFilename: s, dataUrl: f };
}
export {
b as useResponseBody
};