module UrlFormat
Constants
- VERSION
Public Class Methods
ensure_http_prefix(url)
click to toggle source
# File lib/url_format.rb, line 13 def self.ensure_http_prefix(url) return url if url =~ /\Ahttps?:\/\// "http://#{url}" end
get_domain(url)
click to toggle source
# File lib/url_format.rb, line 7 def self.get_domain(url) host = URI.parse(ensure_http_prefix(url)).host.downcase host.start_with?('www.') ? host[4..-1] : host rescue URI::InvalidURIError, NoMethodError end