-
Notifications
You must be signed in to change notification settings - Fork 23.4k
fix(editor): Import multipart form data from curl command correctly #14898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge found 4 issues across 2 files. View them in mrge.io
@@ -292,5 +292,45 @@ describe('useImportCurlCommand', () => { | |||
expect(parameters.sendBody).toBe(false); | |||
expect(parameters.options.allowUnauthorizedCerts).toBe(true); | |||
}); | |||
|
|||
test('Should parse json body data', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test name 'Should parse json body data' is incorrect as the test is actually parsing form-urlencoded data, not JSON
expect(parameters.url).toBe('https://reqbin.com/echo'); | ||
expect(parameters.method).toBe('POST'); | ||
expect(parameters.sendBody).toBe(true); | ||
expect(parameters.bodyParameters).toEqual({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing verification of the contentType property which should be 'form-urlencoded'
@@ -149,6 +149,14 @@ const extractQueries = (queries: JSONOutput['queries'] = {}): HttpNodeQueries => | |||
}; | |||
|
|||
const jsonBodyToNodeParameters = (body: JSONOutput['data'] = {}): Parameter[] | [] => { | |||
if (typeof body === 'string') { | |||
const parameters = body.split('&'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing URL-decoding for form-urlencoded data. Form data usually contains encoded characters (like %20 for spaces or + for spaces) that need decoding.
const parameters = body.split('&'); | ||
|
||
return parameters.map((parameter) => { | ||
const [key, value] = parameter.split('='); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting by first '=' character can break values containing '=' characters. Form values might include URL parameters or Base64 data containing '=' characters.
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
Summary
curlconverter returns data as string which is not handled at the moment.


before
after
Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)