Merge pull request #4992 from maintainer-bruno/fix/curl-query-parsing

fix(import): handle repeated query keys and improve error handling in curl import
This commit is contained in:
lohit
2025-06-27 17:10:16 +05:30
committed by GitHub
2 changed files with 10 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ function getQueries(request) {
const rawValue = request.query[paramName];
let paramValue;
if (Array.isArray(rawValue)) {
paramValue = rawValue.map(repr);
paramValue = rawValue.map(value => repr(value, false));
} else {
paramValue = repr(rawValue);
}
@@ -139,6 +139,10 @@ function getFilesString(request) {
const curlToJson = (curlCommand) => {
const request = parseCurlCommand(curlCommand);
if (!request?.url) {
return null;
}
const requestJson = {};
// curl automatically prepends 'http' if the scheme is missing, but python fails and returns an error
@@ -207,7 +211,7 @@ const curlToJson = (curlCommand) => {
}
}
return Object.keys(requestJson).length ? requestJson : {};
return Object.keys(requestJson).length ? requestJson : null;
};
export default curlToJson;

View File

@@ -34,6 +34,10 @@ export const getRequestFromCurlCommand = (curlCommand, requestType = 'http-reque
}
const request = curlToJson(curlCommand);
if (!request || !request.url) {
return null;
}
const parsedHeaders = request?.headers;
const headers =
parsedHeaders &&