question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No match when basePath is regex and path is function

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
deeptiagrawacommented, Jun 9, 2018

Hello, I am working on creating a PR for this bug. The PR will be ready by Monday at the most.

0reactions
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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found