File: escape.rb

package info (click to toggle)
ruby-slack-notifier 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: ruby: 1,076; makefile: 5
file content (16 lines) | stat: -rw-r--r-- 326 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

module Slack
  class Notifier
    module Util
      module Escape
        HTML_REGEXP  = /[&><]/
        HTML_REPLACE = { "&" => "&amp;", ">" => "&gt;", "<" => "&lt;" }.freeze

        def self.html string
          string.gsub(HTML_REGEXP, HTML_REPLACE)
        end
      end
    end
  end
end