Missleading regex example
See original GitHub issueWhen using a regex expression, requests don’t get caught by the adapter in some cases
This works :
const axios = axios.create({
baseURL: 'https://apiurl.com'
})
axios.get('/foo/123').then(function (data) {
console.log(data)
})
mock.onGet(/\/foo\/\d+/).reply(function(config) {
return [200, {}];
})
This doesn’t :
const axios = axios.create({
baseURL: 'https://apiurl.com/'
})
axios.get('/foo/123').then(function (data) {
console.log(data)
})
mock.onGet(/\/foo\/\d+/).reply(function(config) {
return [200, {}];
})
It is due to the trailing slash in the baseURL.
Is there a way to fix that (in handleRequest function for example) or at least change the documentation ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Examples of regular expressions - Google Workspace Admin ...
Examples of regular expressions · baloney · darn · drat · fooey · gosh darnit · heck.
Read more >regex - Is it possible to create wrong Regular expression in ...
I've tried so many weird regexpes in Flex and Flex never complained! How do I know If my regexp valid? regex · apache-flex...
Read more >CWE-185: Incorrect Regular Expression (4.9) - MITRE
Demonstrative Examples. Example 1. The following code takes phone numbers as input, and uses a regular expression to reject invalid phone numbers.
Read more >A look at using Regular Expressions (RegEx) - YouTube
In this video I wanted to explore RegEx as it's so powerful and can ... 59:05 - Example RegEx I use to scrap...
Read more >Regular Expressions :: Eloquent JavaScript
A regular expression is a type of object. It can be either constructed with the RegExp constructor or written as a literal value...
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

2020-08-17 The problem remains unsolved
sure, here is mock regexp mock not working, but with “fix” i wrote above it’s working
i use webpack-everything as a starter in this project, just clone repo, install dependencies and run
open localhost:3000 and navigate to localhost:3000/test then watch console i doubt that this is issue with axios-mock-adapter, but it’s definitely a strange one