Permalink
Browse files

assigning the value of req.path to options.path before trying matches.

…Fixes #130.
  • Loading branch information...
pgte committed Dec 3, 2013
1 parent 22604eb commit 93d4c772554ee2f947cf40b12874fa7b135e018c
Showing with 20 additions and 0 deletions.
  1. +5 −0 lib/request_overrider.js
  2. +15 −0 tests/test_intercept.js
View
@@ -140,6 +140,11 @@ function RequestOverrider(req, options, interceptors, remove, cb) {
requestBody = requestBody.toString();
+ /// put back the path into options
+ /// because bad behaving agents like superagent
+ /// like to change request.path in mid-flight.
+ options.path = req.path;
+
interceptors = interceptors.filter(function(interceptor) {
return interceptor.match(options, requestBody);
});
View
@@ -2030,4 +2030,19 @@ test('superagent works', function(t) {
t.equal(res.text, responseText);
t.end();
});
+});
+
+test('superagent works with query string', function(t) {
+ var responseText = 'Yay superagentzzz';
+ var headers = { 'Content-Type': 'text/plain'};
+ nock('http://superagent.cz')
+ .get('/somepath?a=b')
+ .reply(200, responseText, headers);
+
+ superagent
+ .get('http://superagent.cz/somepath?a=b')
+ .end(function(err, res) {
+ t.equal(res.text, responseText);
+ t.end();
+ });
});

0 comments on commit 93d4c77

Please sign in to comment.