Skip to content

Commit cb93bc7

Browse files
committed
--form & --data were swapped!
1 parent 05a8272 commit cb93bc7

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎src/targets/curl.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ module.exports = function (options) {
3434

3535
// request body
3636
if (this.source.postData.text) {
37-
code.push(util.format('%s %s', opts.short ? '-F' : '--form', JSON.stringify(this.source.postData.text)));
37+
code.push(util.format('%s %s', opts.short ? '-d' : '--data', JSON.stringify(this.source.postData.text)));
3838
}
3939

4040
// construct post params
4141
if (!this.source.postData.text && this.source.postData.params && this.source.postData.params.length) {
4242
this.source.postData.params.map(function (param) {
43-
code.push(util.format('%s "%s=%s"', opts.short ? '-d' : '--data', param.name, param.value));
43+
code.push(util.format('%s "%s=%s"', opts.short ? '-F' : '--form', param.name, param.value));
4444
});
4545
}
4646

‎test/targets/curl.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('cURL', function () {
1111
});
1212

1313
result.should.be.a.String;
14-
result.should.eql('curl --request POST --url "http://mockbin.com/request?foo=bar" --header "Content-Type: application/json" --cookie "bar=baz" --form "{\\"foo\\": \\"bar\\"}"');
14+
result.should.eql('curl --request POST --url "http://mockbin.com/request?foo=bar" --header "Content-Type: application/json" --cookie "bar=baz" --data "{\\"foo\\": \\"bar\\"}"');
1515

1616
done();
1717
});
@@ -23,7 +23,7 @@ describe('cURL', function () {
2323
});
2424

2525
result.should.be.a.String;
26-
result.should.eql('curl -X POST "http://mockbin.com/request?foo=bar" -H "Content-Type: application/json" -b "bar=baz" -F "{\\"foo\\": \\"bar\\"}"');
26+
result.should.eql('curl -X POST "http://mockbin.com/request?foo=bar" -H "Content-Type: application/json" -b "bar=baz" -d "{\\"foo\\": \\"bar\\"}"');
2727

2828
done();
2929
});
@@ -45,7 +45,7 @@ describe('cURL', function () {
4545
});
4646

4747
result.should.be.a.String;
48-
result.replace(/\\\n/g, '').should.eql('curl --request POST @--url "http://mockbin.com/request?foo=bar" @--header "Content-Type: application/json" @--cookie "bar=baz" @--form "{\\"foo\\": \\"bar\\"}"');
48+
result.replace(/\\\n/g, '').should.eql('curl --request POST @--url "http://mockbin.com/request?foo=bar" @--header "Content-Type: application/json" @--cookie "bar=baz" @--data "{\\"foo\\": \\"bar\\"}"');
4949

5050
done();
5151
});

0 commit comments

Comments
 (0)