module FormatUrl

Constants

VERSION

Public Class Methods

format_url(url) click to toggle source
# File lib/format_url.rb, line 6
def self.format_url(url)
  if url && url.length > 0 && url.to_s !~ url_regexp && "http://#{url}" =~ url_regexp
    "http://#{url}"
  else
    url
  end
end
url_regexp() click to toggle source
# File lib/format_url.rb, line 14
def self.url_regexp
  /\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[-[[:alnum:]]]+(\.[-[[:alnum:]]]+)+\.?(:\d{1,5})?([\/?]\S*)?\z/iux
end