mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 18:29:54 +08:00
74f7295631
The generated regular expressions did not contain \b which matched every text that contained the word, even if it was only a substring of a word. For example, if "art" was a watched word a post containing word "artist" matched.
18 lines
347 B
Ruby
18 lines
347 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WatchedWordSerializer < ApplicationSerializer
|
|
attributes :id, :word, :regexp, :replacement, :action
|
|
|
|
def regexp
|
|
WordWatcher.word_to_regexp(word, whole: true)
|
|
end
|
|
|
|
def action
|
|
WatchedWord.actions[object.action]
|
|
end
|
|
|
|
def include_replacement?
|
|
WatchedWord.has_replacement?(action)
|
|
end
|
|
end
|