Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path after wildcard not recognized #63

Open
spooler opened this issue Jan 31, 2019 · 2 comments
Open

Path after wildcard not recognized #63

spooler opened this issue Jan 31, 2019 · 2 comments

Comments

@spooler
Copy link

spooler commented Jan 31, 2019

mockserver 3.0.0

file:

foo/__/bar/GET.mock

request:

/foo/1/bar

expected server output:

Reading from foo/1/bar/GET.mock file: Not matched
Reading from foo/__/bar/GET.mock file: Matched

got:

Reading from foo/1/bar/GET.mock file: Not matched
Reading from foo/__/GET.mock file: Not matched
@derit
Copy link

derit commented Aug 10, 2019

same issue on osx

@benaud12
Copy link

benaud12 commented Nov 1, 2019

Was having this same issue and the problem for me was in how I declared the path to my mocks.

In short, I was setting up the mockserver like this:

mockserver("./path/to/mocks")

and the problem was caused by the leading ./, so just removing that solved the problem for me:

mockserver("path/to/mocks")

The reason this breaks the wildcard matching is because it strips off the base directory from the wildcard filepaths (

const baseDir = mockserver.directory.split(path.sep);
), but it does this by calculating the number of path segments in the base directory and removing them from the wildcard filepaths. However if your base directory includes the leading ./ it will be counted as an additional segment and therefore no matches will be found.

Don't know if this is the reason for the issues above but just putting it here for anyone else who comes across the same problem I did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants