Skip to content

Commit d41bd57

Browse files
committed
minor refactoring
1 parent 80d8017 commit d41bd57

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/sasl.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ var SaslClient = function (connection, mechanisms, hostname) {
224224
};
225225

226226
SaslClient.prototype.on_sasl_mechanisms = function (frame) {
227-
const frame_sasl_mechanisms = (typeof frame.performative.sasl_server_mechanisms === 'undefined' || frame.performative.sasl_server_mechanisms === null)
228-
? []
229-
: (!Array.isArray(frame.performative.sasl_server_mechanisms)
230-
? [ frame.performative.sasl_server_mechanisms ]
231-
: frame.performative.sasl_server_mechanisms);
232-
233-
for (var i = 0; this.mechanism === undefined && i < frame_sasl_mechanisms.length; i++) {
234-
var mech = frame_sasl_mechanisms[i];
227+
var offered_mechanisms = [];
228+
if (Array.isArray(frame.performative.sasl_server_mechanisms)) {
229+
offered_mechanisms = frame.performative.sasl_server_mechanisms;
230+
} else if (frame.performative.sasl_server_mechanisms) {
231+
offered_mechanisms = [frame.performative.sasl_server_mechanisms];
232+
}
233+
for (var i = 0; this.mechanism === undefined && i < offered_mechanisms.length; i++) {
234+
var mech = offered_mechanisms[i];
235235
var f = this.mechanisms[mech];
236236
if (f) {
237237
this.mechanism = typeof f === 'function' ? f() : f;

0 commit comments

Comments
 (0)