From 70a7d947bc1f8568c347d882914cc335fe68ab81 Mon Sep 17 00:00:00 2001 From: Katherine Walker Date: Tue, 26 Mar 2019 15:58:23 -0400 Subject: [PATCH] fix(uri_parser): restore original compression parsing --- lib/uri_parser.js | 6 ++++++ test/tests/unit/connection_string_tests.js | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/uri_parser.js b/lib/uri_parser.js index 4965f1053..4b67a6fb6 100644 --- a/lib/uri_parser.js +++ b/lib/uri_parser.js @@ -264,6 +264,12 @@ function applyConnectionStringOption(obj, key, value, options) { throw new MongoParseError('zlibCompressionLevel must be an integer between -1 and 9'); } + // special cases + if (key === 'compressors' || key === 'zlibcompressionlevel') { + obj.compression = obj.compression || {}; + obj = obj.compression; + } + if (key === 'authmechanismproperties') { if (typeof value.SERVICE_NAME === 'string') obj.gssapiServiceName = value.SERVICE_NAME; if (typeof value.SERVICE_REALM === 'string') obj.gssapiServiceRealm = value.SERVICE_REALM; diff --git a/test/tests/unit/connection_string_tests.js b/test/tests/unit/connection_string_tests.js index 904a6bcce..b3e2940bd 100644 --- a/test/tests/unit/connection_string_tests.js +++ b/test/tests/unit/connection_string_tests.js @@ -100,8 +100,11 @@ describe('Connection String', function() { 'mongodb://localhost/?compressors=zlib&zlibCompressionLevel=4', (err, result) => { expect(err).to.not.exist; - expect(result.options.compressors).to.eql(['zlib']); - expect(result.options.zlibCompressionLevel).to.equal(4); + expect(result.options).to.have.property('compression'); + expect(result.options.compression).to.eql({ + compressors: ['zlib'], + zlibCompressionLevel: 4 + }); done(); }