Skip to content

Commit

Permalink
Partial fix for #5 and implement #1: use single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcg committed Aug 8, 2023
1 parent 6a206f2 commit 2d3fac4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/har-to-curl.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,24 @@ harToCurl.fromEntry = function(entry) {
}

if (request.cookies.length) {
command += ' -b "' + request.cookies.map(function(cookie) {
command += ' -b \'' + request.cookies.map(function(cookie) {
return encodeURIComponent(cookie.name) + '=' + encodeURIComponent(cookie.value);
}).join('&') + '"';
}).join('&') + '\'';
}

command += request.headers.map(function(header) {
return ' -H "' + header.name + ': ' + header.value + '"';
return ' -H \'' + header.name + ': ' + header.value + '\'';
}).join('');

if (request.postData) {
if (request.postData.text) {
command += ' -d "' + request.postData.text + '"';
command += ' -d \'' + request.postData.text + '\'';
} else if (request.postData.params && request.postData.params.length > 0) {
command += ' -d "' + request.postData.params.map(function(param) {
command += ' -d \'' + request.postData.params.map(function(param) {
return param.name + '=' + param.value;
}).join('&') + '"';
}).join('&') + '\'';
}
}

return command + ' ' + request.url;
return command + ' \'' + encodeURI(request.url) + '\'';
};

0 comments on commit 2d3fac4

Please sign in to comment.