Add a leading / if the path doesn't have it
See original GitHub issueRecently, 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.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Add directory to $PATH if it's not already there - Super User
If I construct my PATH in .bashrc, then it runs with each subshell. So if I launch a Terminal window and then run...
Read more >urljoin when an absolute path does not have a leading slash
python - urljoin when an absolute path does not have a leading slash - Stack Overflow. Stack Overflow for Teams – Start collaborating...
Read more >How to correctly add a path to PATH? - Unix Stack Exchange
The simple stuff. PATH=$PATH:~/opt/bin. or. PATH=~/opt/bin:$PATH. depending on whether you want to add ~/opt/bin at the end (to be searched ...
Read more >OperatingSystem - Robot Framework
If the path to the file does not exist, it is created. The resulting destination path is returned. See also Copy Files, Move...
Read more >ansible.builtin.file module – Manage files and file properties
This module is part of ansible-core and included in all Ansible installations. ... Note that absent will not cause file to fail if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, I’ve been quite busy since the end of last year. I’m going to spend some time working on this tomorrow.
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.