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:
shubh-bruno
2026-02-12 21:10:04 +05:30
committed by GitHub
parent e03cf9a519
commit 3e581675cd
2 changed files with 9 additions and 1 deletions

View File

@@ -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);
};

View File

@@ -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;