Recently, we bumped into an issue with nock in which it won't catch a request we were sure was being mocked correctly. We were wondering for a while until .log(console.log) shed some light on what the issue was.
We noticed our host url didn't have a trailing slash (http://localhost:3000) while at the same time our mocked path didn't have a leading slash (api/bot/request.json). Turns out knock was trying to match our url with http://localhost:3000api/bot/request.json, no slash separating the host and path segments.
I was wondering if we can have nock add that slash by itself when is not present.
I can submit a PR if you guys want.
I think that sounds like a pretty clear bug to fix. A PR would be great for this, especially with some accompanying tests.
Hi @kevinnio, any progress with this? :)
Sorry, I've been quite busy since the end of last year. I'm going to spend some time working on this tomorrow.
So, just finished my first attempt to it. Ready for review.
Given https://github.com/nock/nock/pull/1391#discussion_r250725610, we decided to make nock raise an error whenever the user forgets to add a leading slash into the intercepted path, instead of adding it itself.
:tada: This issue has been resolved in version 11.0.0-beta.5 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This issue has been resolved in version 11.0.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Most helpful comment
Sorry, I've been quite busy since the end of last year. I'm going to spend some time working on this tomorrow.