forwardemail / forwardemail/superagent
unexpected behaviour on usage of .query on url with existing querystring
- Dominant language
- JavaScript
- Stars
- 16.6k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
calling `.query(object)` with a url that has an existing query string will just append the query object to the existing url.
There is no documentation for this case so I assumed it would merge/override existing query parameters that came with the url.
I created this failing test case under test/request.js to demonstrate the issue:
```
it('GET querystring?search=Manny with query object with same query parameters', function(next){
request.get(uri + '/querystring?search=Manny')
.query({ search: 'Buzz' })
.end(function(err, res){
//assert.deepEqual(res.body, { search: 'Buzz'});
assert.equal(res.req.path, '/querystring?search=Buzz');
// ^^ the result is /querystring?search=Buzz&search=Manny
next();
});
});
```
**this happens since version 1.7.0.**
**behaviour on v1.6.1:**
original query string remains untouched, parameters from new query object that already exist in original are not appended.
what is your take on this?
Contributor guide
Assessment
This issue has not been assessed yet.