Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(uri_parser): restore original compression parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kvwalker authored Mar 26, 2019
1 parent c067dbc commit 70a7d94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/uri_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions test/tests/unit/connection_string_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 70a7d94

Please sign in to comment.