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