diff --git a/app/lib/email_checker.rb b/app/lib/email_checker.rb index c2cbe3536..e2d2d5222 100644 --- a/app/lib/email_checker.rb +++ b/app/lib/email_checker.rb @@ -627,6 +627,8 @@ class EmailChecker return { success: true } if similar_domains.empty? { success: true, email_suggestions: email_suggestions(parsed_email:, similar_domains:) } + rescue Mail::Field::IncompleteParseError + return { success: false } end private diff --git a/spec/controllers/email_checker_controller_spec.rb b/spec/controllers/email_checker_controller_spec.rb index 4572c2cd4..685bd5de9 100644 --- a/spec/controllers/email_checker_controller_spec.rb +++ b/spec/controllers/email_checker_controller_spec.rb @@ -35,5 +35,13 @@ describe EmailCheckerController, type: :controller do expect(body).to eq({ success: false }) end end + + context 'incomplete' do + let(:params) { { email: 'bikram.subedi81@' } } + it do + expect(response).to have_http_status(:success) + expect(body).to eq({ success: false }) + end + end end end