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

HTTP method is ignored when matching the path by function #1171

Closed
nicolasprade opened this issue Jul 19, 2018 · 3 comments
Closed

HTTP method is ignored when matching the path by function #1171

nicolasprade opened this issue Jul 19, 2018 · 3 comments

Comments

@nicolasprade
Copy link

Environment info

  • nock version: 9.3.3 and above

Code example

const nock = require('nock');
const http = require('http');

nock('http://example.com')
  .get(uri => (uri === "/foo")).reply(200, 'matched GET')
  .options(uri => (uri === "/foo")).reply(200, 'matched OPTIONS')
  .post(uri => (uri === "/foo")).reply(200, 'matched POST');

http.request({
    host: 'example.com',
    method: 'POST',
    path: '/foo',
  },
  res => {
    res.setEncoding('utf8');
    res.on('data', data => {
      console.log(data);
    });
  })
  .end();

Actual behavior
Prints: matched GET

Expected behavior
Prints: matched POST

More information
nock ^9.3.3 picks the first interceptor that has a matching path function, ignoring the HTTP method.

Related issues

@gr2m
Copy link
Member

gr2m commented Jul 23, 2018

closed via #1172

@gr2m gr2m closed this as completed Jul 23, 2018
@nockbot
Copy link
Collaborator

nockbot commented Jul 23, 2018

🎉 This issue has been resolved in version 9.4.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lock
Copy link

lock bot commented Sep 13, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

@lock lock bot locked as resolved and limited conversation to collaborators Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants