diff --git a/lib/profanity_filter.rb b/lib/profanity_filter.rb index 4e01078..2faf06d 100644 --- a/lib/profanity_filter.rb +++ b/lib/profanity_filter.rb @@ -34,7 +34,8 @@ class Base DICTIONARY = YAML.load_file(File.join(File.dirname(__FILE__), '../config/dictionary.yml')) def self.clean(text, replace_method = '') - text.split(/(\W)/).collect{|word| replace_method == 'dictionary' ? clean_word_dictionary(word) : clean_word_basic(word)}.join rescue nil + return text if text.blank? + text.split(/(\W)/).collect{|word| replace_method == 'dictionary' ? clean_word_dictionary(word) : clean_word_basic(word)}.join end def self.clean_word_dictionary(word)