mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 12:45:38 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user