FIX: Missing word boundaries when non-regexp

This commit is contained in:
Robin Ward 2017-11-17 14:37:31 -05:00
parent d755c9c90f
commit 3785429948

View File

@ -19,7 +19,7 @@ class WordWatcher
nil
else
regexp = '(' + words.map { |w| word_to_regexp(w) }.join('|'.freeze) + ')'
SiteSetting.watched_words_regular_expressions? ? regexp : "(#{regexp})"
SiteSetting.watched_words_regular_expressions? ? regexp : "\\b(#{regexp})\\b"
end
end
s.present? ? Regexp.new(s, Regexp::IGNORECASE) : nil