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

Canned breaks if params contains strange characters #75

Closed xdemocle closed 8 years ago

xdemocle commented 8 years ago

Canned breaks if params contains strange characters. Like: - + %20 etc.

Example:

//! params: {"category": "jonge-vrouwen", "limit": 40, "offset": 0, "withPhotos": 1}
xdemocle commented 8 years ago

Looks like is the regex below that break the matched lines:

var requestMatch = new RegExp(/\/\/! [body|params|header]+: ([\w {}":,@.]*)/g)
xdemocle commented 8 years ago

I temporary resolved like below. But i'm not a RegExp expert. Adding escape for - + \%

var requestMatch = new RegExp(/\/\/! [body|params|header]+: ([\w {}":\-\+\%,@.]*)/g)
sideshowcoder commented 8 years ago

If it passes the test I'm good with it mind sending a PR?

xdemocle commented 8 years ago

Nope, I don't mind... I was just gonna fork