diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb index bf0841b81..83cf57023 100644 --- a/app/helpers/activity_helper.rb +++ b/app/helpers/activity_helper.rb @@ -1,13 +1,20 @@ module ActivityHelper def activity_truncate(message, len = Constants::NAME_TRUNCATION_LENGTH) - activity_title = message.match(/(.*?)<\/strong>/)[1] - if activity_title.length > Constants::NAME_TRUNCATION_LENGTH - title = "" - else - title = truncate(activity_title, length: len) + activity_titles = message.scan(/(.*?)<\/strong>/) + activity_titles.each do |activity_title| + activity_title = activity_title[0] + if activity_title.length > Constants::NAME_TRUNCATION_LENGTH + title = "" + else + title = truncate(activity_title, length: len) + end + message = message.gsub(/#{Regexp.escape(activity_title)}/, title) end - message = message.gsub(/#{activity_title}/, title ) sanitize_input(message) if message end