do not mutate incoming params object

This commit is contained in:
Christoph Neuroth
2014-02-17 17:06:44 +01:00
parent 697c761b71
commit ed3274547e
2 changed files with 11 additions and 1 deletions

View File

@ -118,7 +118,7 @@ var castType = {
}; };
function resolveUrl(url, params) { function resolveUrl(url, params) {
var vars = {}, i, key; var vars = {}, i, key, params = _.clone(params);
if (url.req) { if (url.req) {
// url has required params // url has required params

View File

@ -813,6 +813,16 @@ describe('Client Action runner', function () {
done(); done();
}); });
}); });
it('does not modify the incoming params object', function () {
var action = makeClientAction({ url: { req: { index: { type: 'string' } } } }),
params = { index: 'index' },
before = JSON.stringify(params);
action(params);
expect(JSON.stringify(params)).to.equal(before);
});
}); });
}); });