discourse/app/serializers/watched_word_serializer.rb
Selase Krakani b3bb3872cf
FIX: Make serialized watched word regex Javascript compatible (#22010)
This change ensures Javascript compatible regex is serialized instead of
the default ruby based one.
2023-06-09 10:22:41 +00:00

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