Sha256: 9720f0acc5ef2d0de2be6364f594671b9ccf8c3a07ac3df27330e802dea00708

Contents?: true

Size: 414 Bytes

Versions: 1

Compression:

Stored size: 414 Bytes

Contents

require "format_url/version"
require "format_url/model_additions"
require "format_url/railtie" if defined? Rails

module FormatUrl
  def self.format_url(url)
    if url.to_s !~ url_regexp && "http://#{url}" =~ url_regexp
      "http://#{url}"
    else
      url
    end
  end

  def self.url_regexp
    /\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[-[[:alnum:]]]+(\.[-[[:alnum:]]]+)+\.?(:\d{1,5})?([\/?]\S*)?\z/iux
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
format_url-0.0.3 lib/format_url.rb