From 48f8916c9c834f482b00b6e17609980a87d9a09c Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Thu, 22 Dec 2011 05:09:14 -0800 Subject: [PATCH] Fixed array support. Closes #35 [node] --- lib/node/index.js | 2 +- test/node/json.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/node/index.js b/lib/node/index.js index 2f28fcace..bec50c1bf 100644 --- a/lib/node/index.js +++ b/lib/node/index.js @@ -58,7 +58,7 @@ exports.protocols = { */ function isObject(obj) { - return '[object Object]' == toString.call(obj); + return null != obj && 'object' == typeof obj; } /** diff --git a/test/node/json.js b/test/node/json.js index 30f121472..e6a0187e6 100644 --- a/test/node/json.js +++ b/test/node/json.js @@ -29,6 +29,17 @@ describe('req.send(Object)', function(){ done(); }); }) + + it('should work with arrays', function(done){ + request + .post('http://localhost:3001/echo') + .send([1,2,3]) + .end(function(res){ + res.header['content-type'].should.equal('application/json'); + res.text.should.equal('[1,2,3]'); + done(); + }); + }) describe('when called several times', function(){ it('should merge the objects', function(done){