I build up a request, and in the case that the body is XML string and has any attributes, eg. <?xml version="1.0" encoding="UTF-8"?>, the double quotes are not escaped.
This then means when I feed it through the library like the following:
CurlGenerator({
method: request.method as 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
url: request.url,
body: request.body
}),
I receive an error, and can only fix it if I change the body to:
CurlGenerator({
method: request.method as 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
url: request.url,
body: request.body.replace(/"/g, '\\"') // Escape all double quotes
}),
Is it worth considering adding the string escaping into the library directly, or is there a better way already here that I missed?
I imagine we could update
export function rawBodyToString(body: CurlRawBody): string {
return body.content;
}
to
export function rawBodyToString(body: CurlRawBody): string {
return body.content.replace(/"/g, '\\"')
}
Thanks
I build up a request, and in the case that the body is XML string and has any attributes, eg.
<?xml version="1.0" encoding="UTF-8"?>, the double quotes are not escaped.This then means when I feed it through the library like the following:
I receive an error, and can only fix it if I change the body to:
Is it worth considering adding the string escaping into the library directly, or is there a better way already here that I missed?
I imagine we could update
to
Thanks