Skip to content

Commit

Permalink
fixes #1068 curl syntax for JSON -d should escape single quote
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed Jan 10, 2025
1 parent 802f37d commit 17a1180
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,7 @@ ${responseContent}</pre
fetchOptions.body = exampleTextAreaEl.value;
if (requestBodyType.includes('json')) {
try {
curlData = ` -d '${JSON.stringify(JSON.parse(exampleTextAreaEl.value))}' \\\n`;
curlData = ` -d '${JSON.stringify(JSON.parse(exampleTextAreaEl.value.replace(/'/g, "'\\''")))}' \\\n`;
} catch {
// Ignore.
}
Expand Down

0 comments on commit 17a1180

Please sign in to comment.