File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -867,15 +867,30 @@ def connect
867867 def build_prelude_timeouts ( prelude , auth_timeout )
868868 return nil unless auth_timeout
869869
870- timeouts = Array . new ( prelude . size )
871- prelude . each_with_index do |command , index |
872- next if !command || command . empty?
873- name = command . first
874- if name == "AUTH" || ( name == "HELLO" && command . include? ( "AUTH" ) )
875- timeouts [ index ] = auth_timeout
870+ auth_seen = false
871+ timeouts = prelude . map do |command |
872+ if auth_command? ( command )
873+ auth_seen = true
874+ auth_timeout
875+ else
876+ nil
876877 end
877878 end
878- timeouts
879+
880+ auth_seen ? timeouts : nil
881+ end
882+
883+ def auth_command? ( command )
884+ return false unless command &.any?
885+
886+ case command . first
887+ when "AUTH"
888+ true
889+ when "HELLO"
890+ command . size >= 3 && command [ 2 ] == "AUTH"
891+ else
892+ false
893+ end
879894 end
880895end
881896
You can’t perform that action at this time.
0 commit comments