Sha256: a04b5f7b504feb612f27edd09b2b30feabaa665bd63d8058eab5758918542bea
Contents?: true
Size: 634 Bytes
Versions: 13
Compression:
Stored size: 634 Bytes
Contents
# encoding: utf-8 module Apiary::Helpers::JavascriptHelper JS_ESCAPE_MAP = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" } JS_ESCAPE_MAP["\342\200\250".force_encoding(Encoding::UTF_8).encode!] = '
' JS_ESCAPE_MAP["\342\200\251".force_encoding(Encoding::UTF_8).encode!] = '
' def escape_javascript(javascript) if javascript javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) { |match| JS_ESCAPE_MAP[match] } else '' end end alias j escape_javascript end
Version data entries
13 entries across 13 versions & 1 rubygems