Sha256: 56f29e80106f2e03fda6503410eda71fdea7fd53b2f09c563bad1bfc3130e5d1
Contents?: true
Size: 412 Bytes
Versions: 2
Compression:
Stored size: 412 Bytes
Contents
require "English" module URLHelper DOMAIN_REGEXP = %r(https://([^/]+))i WWW_REGEXP = /\Awww[.]/i 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
email_crawler-0.1.1 | lib/email_crawler/url_helper.rb |
email_crawler-0.1.0 | lib/email_crawler/url_helper.rb |