mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: cURL import NDJSON in request body as text (#7002)
* fix: cURL import NDJSON request body as text * fix: cURL import NDJSON request body as text * fix: cURL import NDJSON request body as text * fix: resolved comments for body.text * fix: add NDJSON content type detection --------- Co-authored-by: shubh-bruno <shubh-bruno@shubh-bruno.local>
This commit is contained in:
@@ -6,6 +6,11 @@ const normalizeContentType = (contentType) => {
|
||||
return contentType.toLowerCase();
|
||||
};
|
||||
|
||||
export const isNDJsonLikeContentType = (contentType) => {
|
||||
const normalized = normalizeContentType(contentType);
|
||||
return normalized.includes('application/x-ndjson') || normalized.includes('application/ndjson');
|
||||
};
|
||||
|
||||
export const isJsonLikeContentType = (contentType) => {
|
||||
const normalized = normalizeContentType(contentType);
|
||||
|
||||
@@ -25,5 +30,5 @@ export const isPlainTextContentType = (contentType) => {
|
||||
};
|
||||
|
||||
export const isStructuredContentType = (contentType) => {
|
||||
return isJsonLikeContentType(contentType) || isXmlLikeContentType(contentType) || isPlainTextContentType(contentType);
|
||||
return isNDJsonLikeContentType(contentType) || isJsonLikeContentType(contentType) || isXmlLikeContentType(contentType) || isPlainTextContentType(contentType);
|
||||
};
|
||||
|
||||
@@ -65,6 +65,9 @@ export const getRequestFromCurlCommand = (curlCommand, requestType = 'http-reque
|
||||
if (requestType === 'graphql-request' && (isJsonLikeContentType(contentType) || normalizedContentType.includes('application/graphql'))) {
|
||||
body.mode = 'graphql';
|
||||
body.graphql = parseGraphQL(parsedBody);
|
||||
} else if (normalizedContentType.includes('application/x-ndjson') || normalizedContentType.includes('application/ndjson')) {
|
||||
body.mode = 'text';
|
||||
body.text = parsedBody;
|
||||
} else if (requestType === 'http-request' && request.isDataBinary) {
|
||||
body.mode = 'file';
|
||||
body.file = parsedBody;
|
||||
|
||||
Reference in New Issue
Block a user