MCPcopy Create free account
hub / github.com/EsperoTech/yaade / buildOptions

Function buildOptions

extension/background.js:31–52  ·  view source on GitHub ↗
(request, senderUrl)

Source from the content-addressed store, hash-verified

29}
30
31async function buildOptions(request, senderUrl) {
32 if (!request.req) {
33 return request.options;
34 }
35 const contentType = request.req.data.contentType;
36 if (contentType !== "multipart/form-data") {
37 return request.options;
38 }
39 const options = { ...request.options };
40 const body = await buildFormDataBody(request.req.data.formDataBody, senderUrl);
41 options.body = body;
42 // NOTE: we need to delete the content type header because the browser will automatically set it
43 // with the correct boundary
44 if (options.headers) {
45 for (let key in options.headers) {
46 if (key.toLowerCase() === "content-type") {
47 delete options.headers[key];
48 }
49 }
50 }
51 return options;
52}
53
54async function buildFormDataBody(body, senderUrl) {
55 let host = senderUrl.split("/#/")[0];

Callers 1

sendRequestFunction · 0.85

Calls 1

buildFormDataBodyFunction · 0.85

Tested by

no test coverage detected