sideshowcoder / canned

Server to respond with fake API responses, by using a directory of files for finding out what to say!
213 stars 46 forks source link

Wildcards not working for _someFile.get.json #87

Open schroepf opened 8 years ago

schroepf commented 8 years ago

I have a file called _userAccount.get.json living in some/path/any/another/path/_userAccount.get.json

I want this file to be returned as a JSON response when my client accesses http://localhost:3000/some/path/12345/another/path/userAccount but with canned 0.3.7 this doesn't work. Canned logs: request: get /some/path/12345/another/path/userAccount not found

If I move the file to some/path/any/another/path/userAccount/index.get.json and access http://localhost:3000/some/path/12345/another/path/userAccount/ from the client the expected JSON is returned.

So it seems like the any wildcard is working for index.get.json files, but not for _anyFileName.get.json files.

sideshowcoder commented 8 years ago

That seems like a bug, thanks for reporting! If you have time to provide a testcase that would help a lot.

schroepf commented 8 years ago

When I added the test to canned.spec.js I noticed there is already a test case named 'loads named response from wildcard path for /d/1/bar' which tests this exact scenario - the only difference why this existing test passes and my test fails is that the existing test uses a number for the wildcard portion of the request url whereas my test uses characters - so maybe the issue only occurs if the client doesn't use a number in place of the wildcard

sideshowcoder commented 7 years ago

That is indeed the case I think the regex matches for numbers, I think supporting characters would probably be good as well so.