Class: HrefProtocol::Sanitizer
- Inherits:
-
Object
- Object
- HrefProtocol::Sanitizer
- Defined in:
- lib/href_protocol.rb
Instance Method Summary collapse
- #href ⇒ Object
-
#initialize(value) ⇒ Sanitizer
constructor
A new instance of Sanitizer.
Constructor Details
#initialize(value) ⇒ Sanitizer
Returns a new instance of Sanitizer.
5 6 7 |
# File 'lib/href_protocol.rb', line 5 def initialize(value) @value = value end |
Instance Method Details
#href ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/href_protocol.rb', line 9 def href href = @value.to_s.strip return @value if href.empty? if href =~ %r{\A(/|(https?|ftp|mailto):)}i href else "http://#{href}" end end |