Sha256: e353ca665cda347bac535f7fb2526346c3d3c78b1f696dca50832ba1b9569947
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module ImageScraper module Util def self.absolute_url(url,asset=nil) # TODO - what happens when an index redirect occurs? # Example: 'http://example.com/about' specified as url # 'style.css' specified as asset # url redirects to 'http://example.com/about/' # and serves http://example.com/about/index.html # which then links to the relative asset path 'style.css' # based on original url (http://example.com/about), # self.absolute_url gives # 'http://example.com/style.css # but should get: # 'http://example.com/about/style.css URI.parse(url).merge(URI.parse asset.to_s).to_s end def self.domain(url) uri = URI.parse(url) "#{uri.scheme}://#{uri.host}" end def self.path(url) uri = URI.parse(url) uri.path end def self.strip_backslashes(image_url) image_url.gsub("\\",'') end def self.strip_quotes(image_url) image_url.gsub("'","").gsub('"','') end def self.chomp(image_url) image_url.gsub(/\s/,'') end def self.cleanup_url(image_url) ImageScraper::Util.chomp( ImageScraper::Util.strip_quotes( ImageScraper::Util.strip_backslashes(image_url || ''))) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rcarvalho-image_scraper-0.1.8.7 | lib/image_scraper/util.rb |