Stop adding safeFields to original options arg

This commit is contained in:
Miroslav Bajtoš 2017-01-30 14:48:38 +01:00
parent e6126d1548
commit 936e2d4838
2 changed files with 12 additions and 2 deletions

View File

@ -35,8 +35,8 @@ module.exports = function buildResponseData(err, options) {
fillInternalError(data, err);
}
options.safeFields = options.safeFields || [];
fillSafeFields(data, err, options.safeFields);
var safeFields = options.safeFields || [];
fillSafeFields(data, err, safeFields);
return data;
};

View File

@ -626,6 +626,16 @@ describe('strong-error-handler', function() {
.expect('Content-Type', /^text\/html/, done);
});
});
it('does not modify "options" argument', function(done) {
var options = {log: false, debug: false};
givenErrorHandlerForError(new Error(), options);
request.get('/').end(function(err) {
if (err) return done(err);
expect(options).to.eql({log: false, debug: false});
done();
});
});
});
var app, _requestHandler, request;