From ed3274547e7768778b727796cfc3fa993de898a4 Mon Sep 17 00:00:00 2001 From: Christoph Neuroth Date: Mon, 17 Feb 2014 17:06:44 +0100 Subject: [PATCH] do not mutate incoming params object --- src/lib/client_action.js | 2 +- test/unit/specs/client_action.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/client_action.js b/src/lib/client_action.js index b6db6bbd7..534015f4e 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -118,7 +118,7 @@ var castType = { }; function resolveUrl(url, params) { - var vars = {}, i, key; + var vars = {}, i, key, params = _.clone(params); if (url.req) { // url has required params diff --git a/test/unit/specs/client_action.js b/test/unit/specs/client_action.js index 1980c1a49..4cb357d18 100644 --- a/test/unit/specs/client_action.js +++ b/test/unit/specs/client_action.js @@ -813,6 +813,16 @@ describe('Client Action runner', function () { 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); + }); }); });