javascript - Sinon fakeserver url regexp -


according documentation, sinon fakeserver can use regexp pattern match urls:

server.respondwith(method, urlregexp, response);

i match urls ends foo=1. here attempt:

this.server.respondwith('get', '/foo=1$/', [200,  { 'content-type': 'application/json' }, '{ "foo": 1 }']); 

however, doesn't seem work. regexp wrong, need adjusting it.

http://jsfiddle.net/s38qw3ns/1/

you have single quotes around regular expression, sinon treating string (which :).

get rid of single quotes , regular expression , work expected.

this.server.respondwith('get', /foo=1$/, [200, { 'content-type': 'application/json' }, '{ "foo": 1 }']);

see creating regular expression on mdn reference.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -