mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 06:43:45 +08:00
b3bb3872cf
This change ensures Javascript compatible regex is serialized instead of the default ruby based one.
18 lines
364 B
Ruby
18 lines
364 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WatchedWordSerializer < ApplicationSerializer
|
|
attributes :id, :word, :regexp, :replacement, :action, :case_sensitive
|
|
|
|
def regexp
|
|
WordWatcher.word_to_regexp(word, engine: :js)
|
|
end
|
|
|
|
def action
|
|
WatchedWord.actions[object.action]
|
|
end
|
|
|
|
def include_replacement?
|
|
WatchedWord.has_replacement?(action)
|
|
end
|
|
end
|