From a6c82da043e0bff682fc5615fc0b0a11175b2c60 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Thu, 28 Nov 2024 09:23:24 +0000 Subject: [PATCH] Improve formatting helper --- app/helpers/formatting_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/formatting_helper.rb b/app/helpers/formatting_helper.rb index ffa8b05e9..b30dc4b94 100644 --- a/app/helpers/formatting_helper.rb +++ b/app/helpers/formatting_helper.rb @@ -2,8 +2,7 @@ module FormattingHelper def format_ending(text) return text if text.blank? - first_word = text.split.first - modified_text = first_word == first_word.upcase ? text : lowercase_first_letter(text) + modified_text = lowercase_first_letter(text) ensure_sentence_ending(modified_text) end @@ -17,6 +16,8 @@ module FormattingHelper end def lowercase_first_letter(text) + first_word = text.split.first + return text if first_word == first_word.upcase return text if text.blank? text[0].downcase + text[1..]