mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 23:20:33 +08:00
9a2780397f
Watched words were converted to regular expressions containing \W, which handled only ASCII characters. Using [^[:word]] instead ensures that UTF-8 characters are also handled correctly.
18 lines
351 B
Ruby
18 lines
351 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WatchedWordSerializer < ApplicationSerializer
|
|
attributes :id, :word, :regexp, :replacement, :action, :case_sensitive
|
|
|
|
def regexp
|
|
WordWatcher.word_to_regexp(word)
|
|
end
|
|
|
|
def action
|
|
WatchedWord.actions[object.action]
|
|
end
|
|
|
|
def include_replacement?
|
|
WatchedWord.has_replacement?(action)
|
|
end
|
|
end
|