def convert_to_valid(url)
      return nil if url =~ /.jpg$/i
      url.insert(0, @main_url.first(5)) if url.start_with? '//'
      link = URI(url)
      main_page = URI(@main_url)
      if link && link.scheme && link.scheme.empty?
        link.scheme = main_page.scheme
      elsif link.nil?
        return nil
      end
      if link.scheme =~ /^http/
        request = link.to_s
      else
        request = nil
      end
      request
    rescue
      link
    end
def convert_to_valid(url)
      return nil if url =~ /.jpg$/i
      url.insert(0, @main_url.first(5)) if url.start_with? '//'
      link = URI(url)
      main_page = URI(@main_url)
      if link && link.scheme && link.scheme.empty?
        link.scheme = main_page.scheme
      elsif link.nil?
        return nil
      end
      if link.scheme =~ /^http/
        request = link.to_s
      else
        request = nil
      end
      request
    rescue
      link
    end
check url and try to convert it to valid, remove .jpg links, add scheme to url