Class: Rack::AddressMunging::Strategy::Hex

Inherits:
Object
  • Object
show all
Includes:
Detection
Defined in:
lib/rack/address_munging/strategy/hex.rb

Overview

The :Hex munging strategy

Will replace email addresses and mailto href attributes values with an hexadecimal HTML entities alternative.

Constant Summary

Constants included from Detection

Detection::REGEXP_EMAIL, Detection::REGEXP_LINK, Detection::REGEXP_MAILTO

Instance Method Summary collapse

Methods included from Detection

#email?

Instance Method Details

#apply(munged, original) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/rack/address_munging/strategy/hex.rb', line 13

def apply(munged, original)
  original.each do |part|
    part = part.dup if part.frozen?
    part.gsub!(REGEXP_MAILTO) { |m| maybe_encode(m) }
    part.gsub!(REGEXP_EMAIL)  { |m| maybe_encode(m) }
    munged.write part
  end
end