lib/scrapifier/support.rb
def sf_fix_protocol(path, domain)
      if path =~ %r{^//[^/]+}
        'http:' << path
      else
        "http://#{domain}#{'/' unless path =~ %r{^/[^/]+}}#{path}"
      end
    end
# Fix image URIs that don't have a protocol/domain set.
#
# Example:
#   >> sf_fix_protocol('/assets/image.jpg', 'http://adtangerine.com')
#   => 'http://adtangerine/assets/image.jpg'
#   >> sf_fix_protocol(
#        '//s.ytimg.com/yts/img/youtub_img.png',
#        'https://youtube.com'
#      )
#   => 'https://s.ytimg.com/yts/img/youtub_img.png'
# Arguments:
#   path: (String)
#     - URI path having no protocol/domain set.
#   domain: (String)
#     - Domain that will be prepended into the path.
Fix image URIs that don't have a protocol/domain set.
Fix image URIs that don ' t have a protocol / domain set .
def sf_fix_protocol(path, domain)
      if path =~ %r{^//[^/]+}
        'http:' << path
      else
        "http://#{domain}#{'/' unless path =~ %r{^/[^/]+}}#{path}"
      end
    end
def sf_fix_protocol ( path , domain ) if path =~ %r{ ^//[^/]+ } 'http:' << path else "http://#{domain}#{'/' unless path =~ %r{^/[^/]+}}#{path}" end end
Fix image URIs that don't have a protocol/domain set.
Fix image URIs that don ' t have a protocol / domain set .
path
domain