diff --git a/lib/core/uri_parser.js b/lib/core/uri_parser.js index 1530d88df1..146231662d 100644 --- a/lib/core/uri_parser.js +++ b/lib/core/uri_parser.js @@ -100,7 +100,7 @@ function parseSrvConnectionString(uri, options, callback) { ); } - Object.assign(result.query, record); + result.query = Object.assign({}, record, result.query); } // Set completed options back into the URL object. diff --git a/test/core/unit/mongodb_srv_tests.js b/test/core/unit/mongodb_srv_tests.js index e92ca6e913..13eb00c49b 100644 --- a/test/core/unit/mongodb_srv_tests.js +++ b/test/core/unit/mongodb_srv_tests.js @@ -45,6 +45,10 @@ describe('mongodb+srv', function() { expect(result.options.ssl).to.equal(test[1].options.ssl); } + if (test[1].options && test[1].options.authSource) { + expect(result.options.authsource).to.equal(test[1].options.authSource); + } + if ( test[1].parsed_options && test[1].parsed_options.user &&