From ea83360c194767effc9a28ecb76d00ba6c04b135 Mon Sep 17 00:00:00 2001 From: Miguel Pilar Date: Mon, 18 Nov 2019 14:17:43 -0500 Subject: [PATCH] fix(mongodb+srv): respect overriding SRV-provided properties This PR fixes the spec test and corrects the behavior of the TXT record overriding the querystring by reversing the merge. NODE-2335 --- lib/core/uri_parser.js | 2 +- test/core/unit/mongodb_srv_tests.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 &&