mockserver icon indicating copy to clipboard operation
mockserver copied to clipboard

Path after wildcard not recognized

Open spooler opened this issue 7 years ago • 2 comments

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

spooler avatar Jan 31 '19 02:01 spooler

same issue on osx

derit avatar Aug 10 '19 15:08 derit

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 (https://github.com/namshi/mockserver/blob/200ede1a6e3de9562c3f9caaea20a9203e907e0a/mockserver.js#L175), 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.

benaud12 avatar Nov 01 '19 16:11 benaud12