Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty string vs "/" #1730

Closed
pociej opened this issue Sep 25, 2019 · 2 comments · Fixed by #1744
Closed

empty string vs "/" #1730

pociej opened this issue Sep 25, 2019 · 2 comments · Fixed by #1744
Labels

Comments

@pociej
Copy link

pociej commented Sep 25, 2019

I wouldn't say its bug but maybe its a bit strange behaviour.
Compare two cases

it("should just pass", done => {
  nock("http://test.com")
    .post("")
    .reply(200, function(url, data) {
      return {};
    });
  got.post("http://test.com", {});
  done();
});
it("should just pass", done => {
 nock("http://test.com")
   .post("/")
   .reply(200, function(url, data) {
     return {};
   });
 got.post("http://test.com", {});
 done();
});

The first one fails because got( https://www.npmjs.com/package/got) makes request to http://test.com/ while nock is watching connections to http://test.com. But shouldn't those be equal from nock perspective?

@paulmelnikow
Copy link
Member

Hi! Yea, you're right, the second one is "correct" but it's strange that the first one basically does nothing. There are a few cases like filteringScope() where the path passed to e.g. .post() is ignored, though in any other case it needs to be a string that starts with a /.

It's not very helpful to silently ignore bad input. Would be great to improve our error messages around this (while being thoughtful about backward compatibility for legitimate use cases. Would you be interested in working on that? If not, no worries, we can leave this open.

@nockbot
Copy link
Collaborator

nockbot commented Oct 22, 2019

🎉 This issue has been resolved in version 11.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants