Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

(#175) - Do not manipulate config object

  • Loading branch information...
commit eb276bd9e163183547ec1acd6f9e937b2bab36e3 1 parent 52d9e36
@jo jo authored
Showing with 16 additions and 1 deletion.
  1. +5 −0 nano.js
  2. +11 −1 tests/shared/config.js
View
5 nano.js
@@ -1159,6 +1159,11 @@ module.exports = exports = nano = function database_module(cfg) {
, session : session
};
+ // clone if cfg object
+ if(typeof cfg === 'object') {
+ cfg = _.clone(cfg);
+ }
+
// handle different type of configs
if(typeof cfg === 'string') {
// just an url
View
12 tests/shared/config.js
@@ -59,4 +59,14 @@ specify("shared_config:default_headers", timeout, function (assert) {
, 'Custom headers "x-second-header" not honored');
});
-specify.run(process.argv.slice(2));
+specify("shared_config:clone", timeout, function (assert) {
+ var config = {
+ url: 'http://someurl.com'
+ };
+
+ assert.equal(Nano(config).config.url, config.url, "Simple URL failed");
+ assert.ok(Nano(config).config.request_defaults, "request_defaults not set");
+ assert.ok(!config.request_defaults, "request_defaults set on original object");
+});
+
+specify.run(process.argv.slice(2));
Please sign in to comment.
Something went wrong with that request. Please try again.