enableNetConnect()
no longer works with Regexp-like objects
#1861
Labels
enableNetConnect()
no longer works with Regexp-like objects
#1861
This is not necessarily a bug, but something I would consider an undocumented feature. Before https://github.com/nock/nock/pull/1754/files#diff-503754c07b5098227646f913eee85885R58 it was possible to use
enableNetConnect
with a function, which greatly improved the flexibility of this mechanism.As an example use case, we used to have a constantly changing
Set
of allowed hostnames which tests could add to. This is still possible to achieve by constructing a RegExp but it is much more awkward. There may be other use cases which cannot be converted to a RegExp at all.What is the expected behavior?
This used to work:
What is the actual behavior?
You can no longer use "RegExp-like" objects (with a
test
function) to filter hosts forenableNetConnect()
. It now defaults to a wildcard match matching anything.Possible solutions
test
function?test
functionHow to reproduce the issue
Runkit: 11.7.0
Runkit: 11.7.2
Versions
I would be willing to submit a PR for this over the next few days if you agree that it should be done. I personally think that option
2
might be the best as it would retain the proper typechecks.Thank you!
The text was updated successfully, but these errors were encountered: