No match when basePath is regex and path is function
See original GitHub issueWhen this.uri
is a function
Interceptor.prototype.match
attempts to “string match” method proto://options.host
(GET http://localhost
) against (GET /.*/
).
Examples
// Calling fetch('http://localhost/api/some-endpoint') after the following nocks() result in:
nock(/.*/).get(/.*/).reply(200, blob);
// works => { matchKey: 'http://localhost:80', path: '/api/some-endpoint' }
nock('http://localhost').get(/.*/).reply(200, blob);
// works => { matchKey: 'http://localhost:80', path: '/api/some-endpoint' }
nock('http://localhost').get(() => true).reply(200, blob);
// works => { baseUri: 'GET http://localhost:80', path: '/api/some-endpoint' }
nock(/.*/).get(() => true).reply(200, blob);
// fails => { baseUri: 'GET /.*/', path: '/api/some-endpoint' }
P.S.
For anyone trying to figure out what’s going on with their matching, you can place some console.logs() around node_modules/nock/lib/interceptror.js#307
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Regular expression to match base path - Stack Overflow
Save this question. Show activity on this post. I'm trying to come out with a regular expression to match a certain base path....
Read more >Configure URI Template Regex - MuleSoft Documentation
When configuring URI template regex , you must consider the base path of the ... the Preview Resource Matching option does not indicate...
Read more >Configuring Jest
Thresholds for globs are applied to all files matching the glob. If the file specified by path is not found, an error is...
Read more >path/filepath - Go Packages
Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the...
Read more >Origin Base Path - Akamai TechDocs
With this behavior enabled, you can specify a directory path that is appended to requests for your origin. How it works Let's assume...
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
Hello, I am working on creating a PR for this bug. The PR will be ready by Monday at the most.
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!