mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 08:11:24 +02:00
Better body handling in Postman
This commit is contained in:
@@ -31,5 +31,7 @@ export async function pluginHookImport(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log("HELLO", JSON.stringify(postmanCollection, null, 1));
|
||||||
|
|
||||||
return pluginHookImportPostman(ctx, JSON.stringify(postmanCollection));
|
return pluginHookImportPostman(ctx, JSON.stringify(postmanCollection));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ function importAuth(
|
|||||||
|
|
||||||
function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'headers'> {
|
function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'headers'> {
|
||||||
const body = toRecord(rawBody);
|
const body = toRecord(rawBody);
|
||||||
if ('graphql' in body) {
|
if (body.mode === 'graphql') {
|
||||||
return {
|
return {
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
@@ -186,7 +186,7 @@ function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'head
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else if ('urlencoded' in body) {
|
} else if (body.mode === 'urlencoded') {
|
||||||
return {
|
return {
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@ function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'head
|
|||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else if ('formdata' in body) {
|
} else if (body.mode === 'formdata') {
|
||||||
return {
|
return {
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
@@ -231,7 +231,7 @@ function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'head
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else if ('raw' in body) {
|
} else if (body.mode === 'raw') {
|
||||||
return {
|
return {
|
||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
@@ -245,6 +245,14 @@ function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'head
|
|||||||
text: body.raw ?? '',
|
text: body.raw ?? '',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} else if (body.mode === 'file') {
|
||||||
|
return {
|
||||||
|
headers: [],
|
||||||
|
bodyType: 'binary',
|
||||||
|
body: {
|
||||||
|
filePath: body.file?.src
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return { headers: [], bodyType: null, body: {} };
|
return { headers: [], bodyType: null, body: {} };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user