Skip to content

Commit

Permalink
fix: Allow allowUnmocked = true and regexp paths to work (#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpardue authored and gr2m committed Feb 26, 2018
1 parent e142be7 commit 6817e76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ Interceptor.prototype.match = function match(options, body, hostNameOnly) {
};

Interceptor.prototype.matchIndependentOfBody = function matchIndependentOfBody(options) {
var isRegex = _.isRegExp(this.__nock_scopeKey) && _.isRegExp(this.path);
var isRegex = _.isRegExp(this.path);

var method = (options.method || 'GET').toUpperCase()
, path = options.path
Expand Down
13 changes: 13 additions & 0 deletions tests/test_intercept.js
Original file line number Diff line number Diff line change
Expand Up @@ -4548,6 +4548,19 @@ test('match path using regexp', function (t) {
});
});

test('match path using regexp with allowUnmocked', function (t) {
nock('http://www.pathregex.com', {allowUnmocked: true})
.get(/regex$/)
.reply(200, 'Match regex');

mikealRequest.get('http://www.pathregex.com/resources/regex', function(err, res, body) {
t.type(err, 'null');
t.equal(res.statusCode, 200);
t.equal(body, 'Match regex');
t.end();
});
});

test('remove interceptor for GET resource', function(t) {
var scope = nock('http://example.org')
.get('/somepath')
Expand Down

0 comments on commit 6817e76

Please sign in to comment.