Skip to content

Commit

Permalink
Updated DELETE params to default into query
Browse files Browse the repository at this point in the history
  • Loading branch information
rubikzube committed Jul 15, 2014
1 parent 08e8764 commit a2a8400
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var Client = function(args) {
}

}

this.auth = parseAuth(this.auth);
this.serializer = args.serializer || defaultSerializer;
this.timeout = args.timeout;
Expand Down Expand Up @@ -106,11 +106,11 @@ util.inherits(Client, events.EventEmitter);

// divvy up request parameters according to protocol

if (['get', 'head'].indexOf(instanceMethod) !== -1) {
if (['get', 'head', 'delete'].indexOf(instanceMethod) !== -1) {
und.extend(query, params);
}

if (['post', 'put', 'patch', 'delete'].indexOf(instanceMethod) !== -1) {
if (['post', 'put', 'patch'].indexOf(instanceMethod) !== -1) {
und.extend(requestBody, params);
if (Buffer.isBuffer(requestBody)) {
args.body = requestBody;
Expand Down
10 changes: 5 additions & 5 deletions tests/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ exports.patchBody = function(test) {

exports.deleteParams = function(test) {
client.delete({
url: '/echo-body',
url: '/echo-query',
params: { one: 1, two: 2 },
success: function(data) {
test.deepEqual(data, { one: 1, two: 2 }, 'got back what delete sent as params');
Expand All @@ -79,12 +79,12 @@ exports.deleteParams = function(test) {
});
};

exports.deleteBody = function(test) {
exports.deleteQuery = function(test) {
client.delete({
url: '/echo-body',
body: { one: 1, two: 2 },
url: '/echo-query',
query: { one: 1, two: 2 },
success: function(data) {
test.deepEqual(data, { one: 1, two: 2 }, 'got back what delete sent as body');
test.deepEqual(data, { one: 1, two: 2 }, 'got back what delete sent as query');
test.done();
}
});
Expand Down

0 comments on commit a2a8400

Please sign in to comment.