Skip to content

Commit edaf958

Browse files
committed
Revert changes done for escaping backslash
1 parent c271c7d commit edaf958

File tree

3 files changed

+70
-36
lines changed

3 files changed

+70
-36
lines changed

codegens/curl/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ self = module.exports = {
142142
// Use the long option if `@` is present in the request body otherwise follow user setting
143143
optionName = isAsperandPresent ? '--data-raw' : form('-d', format);
144144
// eslint-disable-next-line max-len
145-
snippet += indent + `${optionName} ${quoteType}${sanitize(rawBody, trim, quoteType, quoteType === '\'')}${quoteType}`;
145+
snippet += indent + `${optionName} ${quoteType}${sanitize(rawBody, trim, quoteType)}${quoteType}`;
146146
break;
147147
}
148148

codegens/curl/test/unit/convert.test.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,6 @@ describe('curl convert function', function () {
3434
});
3535
});
3636

37-
it('should escape backslash in raw bodies', function () {
38-
request = new sdk.Request({
39-
'method': 'POST',
40-
'header': [
41-
{
42-
'key': 'Content-Type',
43-
'value': 'application/json'
44-
}
45-
],
46-
'body': {
47-
'mode': 'raw',
48-
'raw': '{ "foo": "\\" }'
49-
},
50-
'url': {
51-
'raw': 'https://postman-echo.com/post',
52-
'protocol': 'https',
53-
'host': [
54-
'postman-echo',
55-
'com'
56-
],
57-
'path': [
58-
'post'
59-
]
60-
}
61-
});
62-
63-
convert(request, {}, function (error, snippet) {
64-
if (error) {
65-
expect.fail(null, null, error);
66-
}
67-
68-
expect(snippet).to.contain('{ "foo": "\\\\" }');
69-
});
70-
});
71-
7237
it('should return snippet with url in single quote(\')', function () {
7338
request = new sdk.Request({
7439
'method': 'POST',

test/codegen/newman/fixtures/basicCollection.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@
66
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
77
},
88
"item": [
9+
{
10+
"name": "POST raw with quoted text",
11+
"event": [],
12+
"request": {
13+
"method": "POST",
14+
"header": [
15+
{
16+
"key": "Content-Type",
17+
"value": "application/json"
18+
}
19+
],
20+
"body": {
21+
"mode": "raw",
22+
"raw": "{\n \"Hello\": \"{\\\"hello_world\\\": true}\"\n}"
23+
},
24+
"url": {
25+
"raw": "https://postman-echo.com/post",
26+
"protocol": "https",
27+
"host": [
28+
"postman-echo",
29+
"com"
30+
],
31+
"path": [
32+
"post"
33+
]
34+
}
35+
},
36+
"response": []
37+
},
938
{
1039
"name": "Request Headers (With special Characters)",
1140
"event": [
@@ -429,6 +458,46 @@
429458
},
430459
"response": []
431460
},
461+
{
462+
"name": "POST raw with quoted text",
463+
"event": [
464+
{
465+
"listen": "test",
466+
"script": {
467+
"id": "48da0505-470f-4cf3-bb77-30665415af60",
468+
"exec": [
469+
""
470+
],
471+
"type": "text/javascript"
472+
}
473+
}
474+
],
475+
"request": {
476+
"method": "POST",
477+
"header": [
478+
{
479+
"key": "Content-Type",
480+
"value": "application/json"
481+
}
482+
],
483+
"body": {
484+
"mode": "raw",
485+
"raw": "{\n \"Hello\": \"{\\\"hello_world\\\": true}\"\n}"
486+
},
487+
"url": {
488+
"raw": "https://postman-echo.com/post",
489+
"protocol": "https",
490+
"host": [
491+
"postman-echo",
492+
"com"
493+
],
494+
"path": [
495+
"post"
496+
]
497+
}
498+
},
499+
"response": []
500+
},
432501
{
433502
"name": "POST urlencoded data",
434503
"event": [

0 commit comments

Comments
 (0)