docs: function() {
        const AUTH_TOKEN = 'AUTH_TOKEN';
        var req = {
          protocol: this.isSrvRecord ? 'mongodb+srv' : 'mongodb',
          slashes: true,
          hostname: this.hostname,
          port: this.isSrvRecord ? null : this.port,
          pathname: '/',
          query: {}
        };
  
        if (this.replica_set_name) {
          req.query.replicaSet = this.replica_set_name;
        }
  
        req.query.readPreference = this.read_preference;
  
        if (this.app_name) {
          req.query.appname = this.app_name;
        }
  
        if (this.ns) {
          req.pathname = format('/%s', this.ns);
        }
  
        const encodeAuthForUrlFormat = () => {
          if (this.authentication === 'MONGODB') {
            req.auth = AUTH_TOKEN;
            req.query.authSource = this.mongodb_database_name || MONGODB_DATABASE_NAME_DEFAULT;
          } else if (this.authentication === 'SCRAM-SHA-256') {
            req.auth = AUTH_TOKEN;
            req.query.authSource = this.mongodb_database_name || MONGODB_DATABASE_NAME_DEFAULT;
            req.query.authMechanism = this.driver_auth_mechanism;
          } else if (this.authentication === 'KERBEROS') {
            defaults(req.query, {
              gssapiServiceName: this.kerberos_service_name,
              authMechanism: this.driver_auth_mechanism
            });
            req.auth = AUTH_TOKEN;
          } else if (this.authentication === 'X509') {
            req.auth = this.x509_username;
            defaults(req.query, {
              authMechanism: this.driver_auth_mechanism
            });
          } else if (this.authentication === 'LDAP') {
            req.auth = AUTH_TOKEN;
  
            defaults(req.query, {
              authMechanism: this.driver_auth_mechanism
            });
          }
        };
        encodeAuthForUrlFormat();
  
        if (includes(['UNVALIDATED', 'SYSTEMCA', 'SERVER', 'ALL'], this.ssl)) {
          req.query.ssl = 'true';
        } else if (this.ssl === 'IFAVAILABLE') {
          req.query.ssl = 'prefer';
        } else if (this.ssl === 'NONE') {
          req.query.ssl = 'false';
        }
        var reqClone = clone(req);
        if (this.ssh_tunnel !== 'NONE') {
          // Populate the SSH Tunnel options correctly
          reqClone.hostname = this.ssh_tunnel_options.localAddr;
          reqClone.port = this.ssh_tunnel_options.localPort;
        }
        var result = toURL(reqClone);
  
        // Post url.format() workaround for
        // https://github.com/nodejs/node/issues/1802
        if (this.authentication === 'MONGODB' || this.authentication === 'SCRAM-SHA-256') {
          const authField = format(
            '%s:%s',
            encodeURIComponent(this.mongodb_username),
            encodeURIComponent(this.mongodb_password)
          );
  
          // The auth component comes straight after the mongodb:// so
          // a single string replace should always work
          result = result.replace(AUTH_TOKEN, authField, 1);
        }
        if (this.authentication === 'LDAP') {
          const authField = format(
            '%s:%s',
            encodeURIComponent(this.ldap_username),
            encodeURIComponent(this.ldap_password)
          );
          result = result.replace(AUTH_TOKEN, authField, 1);
          result = `${result}&authSource=$external`;
        }
        if (this.authentication === 'KERBEROS') {
          if (this.kerberos_password) {
            const authField = format(
              '%s:%s',
              encodeURIComponent(this.kerberos_principal),
              encodeURIComponent(this.kerberos_password)
            );
            result = result.replace(AUTH_TOKEN, authField, 1);
          } else {
            const authField = format(
              '%s:',
              encodeURIComponent(this.kerberos_principal)
            );
            result = result.replace(AUTH_TOKEN, authField, 1);
          }
          result = `${result}&authSource=$external`;
          if (this.kerberos_canonicalize_hostname) {
            result = `${result}&authMechanismProperties=CANONICALIZE_HOST_NAME:true`;
          }
        }
        return result;
      }