module URLHelper

Constants

DOMAIN_REGEXP
WWW_REGEXP

Public Instance Methods

extract_domain_from(url, www = false) click to toggle source
# File lib/email_crawler/url_helper.rb, line 7
def extract_domain_from(url, www = false)
  uri = begin
          URI(url)
        rescue URI::InvalidURIError
          return
        end
  host = uri.host || url[DOMAIN_REGEXP, 1].to_s

  if www || host !~ WWW_REGEXP
    host.downcase
  else
    $POSTMATCH.downcase
  end
end