Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

18 lines (15 sloc) 0.425 kb
require "url_formatter/version"
require "url_formatter/model_additions"
require "url_formatter/railtie" if defined? Rails
module UrlFormatter
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
/^https?:\/\/([^\s:@]+:[^\s:@]*@)?[-[[:alnum:]]]+(\.[-[[:alnum:]]]+)+\.?(:\d{1,5})?([\/?]\S*)?$/iux
end
end
Jump to Line
Something went wrong with that request. Please try again.