docs: function parseConnectionString(uri, options, callback) {
    if (typeof options === 'function') (callback = options), (options = {});
    options = Object.assign({}, { caseTranslate: true }, options);
  
    // Check for bad uris before we parse
    try {
      URL.parse(uri);
    } catch (e) {
      return callback(new MongoParseError('URI malformed, cannot be parsed'));
    }
  
    const cap = uri.match(HOSTS_RX);
    if (!cap) {
      return callback(new MongoParseError('Invalid connection string'));
    }
  
    const protocol = cap[1];
    if (SUPPORTED_PROTOCOLS.indexOf(protocol) === -1) {
      return callback(new MongoParseError('Invalid protocol provided'));
    }
  
    if (protocol === PROTOCOL_MONGODB_SRV) {
      return parseSrvConnectionString(uri, options, callback);
    }
  
    const dbAndQuery = cap[4].split('?');
    const db = dbAndQuery.length > 0 ? dbAndQuery[0] : null;
    const query = dbAndQuery.length > 1 ? dbAndQuery[1] : null;
  
    let parsedOptions;
    try {
      parsedOptions = parseQueryString(query, options);
    } catch (parseError) {
      return callback(parseError);
    }
  
    parsedOptions = Object.assign({}, parsedOptions, options);
    const auth = { username: null, password: null, db: db && db !== '' ? qs.unescape(db) : null };
    if (parsedOptions.auth) {
      // maintain support for legacy options passed into `MongoClient`
      if (parsedOptions.auth.username) auth.username = parsedOptions.auth.username;
      if (parsedOptions.auth.user) auth.username = parsedOptions.auth.user;
      if (parsedOptions.auth.password) auth.password = parsedOptions.auth.password;
    }
  
    if (cap[4].split('?')[0].indexOf('@') !== -1) {
      return callback(new MongoParseError('Unescaped slash in userinfo section'));
    }
  
    const authorityParts = cap[3].split('@');
    if (authorityParts.length > 2) {
      return callback(new MongoParseError('Unescaped at-sign in authority section'));
    }
  
    if (authorityParts.length > 1) {
      const authParts = authorityParts.shift().split(':');
      if (authParts.length > 2) {
        return callback(new MongoParseError('Unescaped colon in authority section'));
      }
  
      auth.username = qs.unescape(authParts[0]);
      auth.password = authParts[1] ? qs.unescape(authParts[1]) : null;
    }
  
    let hostParsingError = null;
    const hosts = authorityParts
      .shift()
      .split(',')
      .map(host => {
        let parsedHost = URL.parse(`mongodb://${host}`);
        if (parsedHost.path === '/:') {
          hostParsingError = new MongoParseError('Double colon in host identifier');
          return null;
        }
  
        // heuristically determine if we're working with a domain socket
        if (host.match(/\.sock/)) {
          parsedHost.hostname = qs.unescape(host);
          parsedHost.port = null;
        }
  
        if (Number.isNaN(parsedHost.port)) {
          hostParsingError = new MongoParseError('Invalid port (non-numeric string)');
          return;
        }
  
        const result = {
          host: parsedHost.hostname,
          port: parsedHost.port ? parseInt(parsedHost.port) : 27017
        };
  
        if (result.port === 0) {
          hostParsingError = new MongoParseError('Invalid port (zero) with hostname');
          return;
        }
  
        if (result.port > 65535) {
          hostParsingError = new MongoParseError('Invalid port (larger than 65535) with hostname');
          return;
        }
  
        if (result.port < 0) {
          hostParsingError = new MongoParseError('Invalid port (negative number)');
          return;
        }
  
        return result;
      })
      .filter(host => !!host);
  
    if (hostParsingError) {
      return callback(hostParsingError);
    }
  
    if (hosts.length === 0 || hosts[0].host === '' || hosts[0].host === null) {
      return callback(new MongoParseError('No hostname or hostnames provided in connection string'));
    }
  
    const result = {
      hosts: hosts,
      auth: auth.db || auth.username ? auth : null,
      options: Object.keys(parsedOptions).length ? parsedOptions : null
    };
  
    if (result.auth && result.auth.db) {
      result.defaultDatabase = result.auth.db;
    }
  
    try {
      applyAuthExpectations(result);
    } catch (authError) {
      return callback(authError);
    }
  
    callback(null, result);
  }