1
0
mirror of synced 2025-12-23 11:54:18 -05:00

Fix single quote escaping for curl examples (#29876)

fix single quote escaping for curl examples
This commit is contained in:
Grace Park
2022-08-11 15:26:58 -07:00
committed by GitHub
parent 1897eb1c94
commit 0426962aec

View File

@@ -25,7 +25,10 @@ export function getShellExample(operation: Operation, codeSample: CodeSample) {
let requestBodyParams = ''
if (codeSample?.request?.bodyParameters) {
requestBodyParams = `-d '${JSON.stringify(codeSample.request.bodyParameters)}'`
requestBodyParams = `-d '${JSON.stringify(codeSample.request.bodyParameters).replace(
/'/g,
"'\\''"
)}'`
// If the content type is application/x-www-form-urlencoded the format of
// the shell example is --data-urlencode param1=value1 --data-urlencode param2=value2