Module: HelpfulUtils::CoreExt::String::UrlHelpers

Included in:
String
Defined in:
lib/helpful_utils/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#to_url(prefix = "http://") ⇒ Object

can raise URI::InvalidURIError приводит строку к полноценному URL



40
41
42
43
44
45
46
47
# File 'lib/helpful_utils/core_ext/string.rb', line 40

def to_url(prefix="http://")
  return nil if self.blank?
  if  URI.parse(self).class != URI::HTTP
    "#{prefix}#{self.strip}"
  else
    self.dup
  end
end