Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
// Possible Errors
"for-direction": "error",
Expand Down
4 changes: 3 additions & 1 deletion codegens/curl/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var self = module.exports = {
*
* @param {String} inputString
* @param {Boolean} [trim] - indicates whether to trim string or not
* @param {Boolean} [quoteType] - indicates which quoteType has to be escaped
* @param {String} [quoteType] - indicates which quoteType has to be escaped
* @param {Boolean} [backSlash] - indicates whether to escape backslash(\\)
* @returns {String}
*/
Expand All @@ -20,6 +20,8 @@ var self = module.exports = {

if (quoteType === '"') {
inputString = inputString.replace(/"/g, '\\"');
// Escape backslash if double quote was already escaped before call to sanitize
inputString = inputString.replace(/(?<!\\)\\\\"/g, '\\\\\\"');
}
else if (quoteType === '\'') {
// for curl escaping of single quotes inside single quotes involves changing of ' to '\''
Expand Down
32 changes: 32 additions & 0 deletions codegens/curl/test/unit/convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,38 @@ describe('curl convert function', function () {
});
});

it('should not add appropriate escaping characters when quote type is "double"', function () {
var request = new sdk.Request({
'method': 'POST',
'header': [],
'body': {
'mode': 'graphql',
'graphql': {
'query': '{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: "performers"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}', // eslint-disable-line
'variables': '{\n\t"variable_key": "variable_value"\n}'
}
},
'url': {
'raw': 'https://postman-echo.com/post',
'protocol': 'https',
'host': [
'postman-echo',
'com'
],
'path': [
'post'
]
}
});
convert(request, { quoteType: 'double', lineContinuationCharacter: '^' }, function (error, snippet) {
if (error) {
expect.fail(null, null, error);
}

expect(snippet).to.include('{\\"query\\":\\"{\\n findScenes(\\n filter: {per_page: 0}\\n scene_filter: {is_missing: \\\\\\"performers\\\\\\"})'); // eslint-disable-line
});
});

describe('getUrlStringfromUrlObject function', function () {
var rawUrl, urlObject, outputUrlString;

Expand Down
2 changes: 1 addition & 1 deletion test/codegen/newman/fixtures/basicCollection.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
"body": {
"mode": "graphql",
"graphql": {
"query": "{\n body{\n graphql\n }\n}",
"query": "{\n findScenes(\n filter: {per_page: 0}\n scene_filter: {is_missing: \"performers\"}){\n count\n scenes {\n id\n title\n path\n }\n }\n}",
"variables": "{\n\t\"variable_key\": \"variable_value\"\n}"
}
},
Expand Down