Superagent runs encodeURIComponent on all query keys. However, RFC3986 defines a number of characters (sub-delims) which may be used unencoded in the query part of a url, including comma and a few more like +'!$()*;.
This means you can't use superagent to query a valid url like /id?key=val1,val2.
It also means superagent is incompatible with a lot of other url software like curl, chrome, python-requests and npm request.
This should be documented. Ideally, superagent should leave encoding to the user, although this would be a breaking change. Or, have an option to disable encoding.
I believe you can disable encoding by passing a full query string to .query instead of an object.
You're right, this works as expected:
request
.get('http://localhost/id')
.query('key=val1,val2')
.end(function(err, res) {
console.log(res.text);
});
Thanks for the workaround.
Most helpful comment
I believe you can disable encoding by passing a full query string to
.queryinstead of an object.