You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interceptors should match correct request even when using filteringScope option
What is the actual behavior?
Typically interceptors work in any order. However, when using filteringScope option, they misbehave and don't match.
How to reproduce the issue
Take the following for example.
nock('http://some.test',{filteringScope: scope=>true,}).get('/path1?query=1').reply(200,'response for path1/query1').get('/path2?query=2').reply(200,'response for path2/query2')
Here, if I make the request for /path2?query=2first, it fails. Because the filteringScope returns true and it tries to match the path of /path2?query=2 against the first interceptor.
Possible solution
Here we return interceptors as soon as we find the one with filteringScope option. By doing this, we skip setting interceptor.__nock_filteredScope on the "actual" interceptor that should have been matched. Hence, if we return after the inner loop is over, then that should work.
Instead of RunKit, I'm opening a PR with two test cases to demonstrate the problem.
Having problem producing a test case? Try and ask the community for help. If the test case cannot be reproduced, the Nock community might not be able to help you.
Does the bug have a test case?
Versions
Software
Version(s)
Nock
latest
Node
10
TypeScript
-
The text was updated successfully, but these errors were encountered:
What is the expected behavior?
Interceptors should match correct request even when using
filteringScope
optionWhat is the actual behavior?
Typically interceptors work in any order. However, when using
filteringScope
option, they misbehave and don't match.How to reproduce the issue
Take the following for example.
Here, if I make the request for
/path2?query=2
first, it fails. Because thefilteringScope
returnstrue
and it tries to match the path of/path2?query=2
against the first interceptor.Possible solution
Here we
return interceptors
as soon as we find the one withfilteringScope
option. By doing this, we skip settinginterceptor.__nock_filteredScope
on the "actual" interceptor that should have been matched. Hence, if we return after the inner loop is over, then that should work.Instead of RunKit, I'm opening a PR with two test cases to demonstrate the problem.
Having problem producing a test case? Try and ask the community for help. If the test case cannot be reproduced, the Nock community might not be able to help you.
Does the bug have a test case?
Versions
The text was updated successfully, but these errors were encountered: