Skip to content

Commit

Permalink
Fixed: port existing query-string fix (browser). Closes #57
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jan 25, 2012
1 parent d8c2758 commit 42218cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/superagent.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,10 @@ var superagent = function(exports){

// querystring
if ('GET' == this.method && data) {
this.url += '?' + exports.serializeObject(data);
data = exports.serializeObject(data);
this.url += ~this.url.indexOf('?')
? '&' + data
: '?' + data;
data = null;
}

Expand Down
12 changes: 11 additions & 1 deletion test/test.request.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,16 @@ test('GET querystring object', function(next){
});
});

test('GET querystring append original', function(next){
request
.get('/querystring?search=Manny')
.send({ range: '1..5' })
.end(function(res){
assert.eql(res.body, { search: 'Manny', range: '1..5' });
next();
});
});

test('GET querystring multiple objects', function(next){
request
.get('/querystring')
Expand All @@ -372,7 +382,7 @@ test('GET querystring multiple objects', function(next){

test('GET querystring object .get(uri, obj)', function(next){
request
.get('/querystring', { search: 'Manny'})
.get('/querystring', { search: 'Manny' })
.end(function(res){
assert.eql(res.body, { search: 'Manny' });
next();
Expand Down

0 comments on commit 42218cb

Please sign in to comment.