lib/spidr/page/html.rb
def to_absolute(link)
      link    = link.to_s
      new_url = begin
                  url.merge(link)
                rescue Exception
                  return
                end

      if (!new_url.opaque) && (path = new_url.path)
        # ensure that paths begin with a leading '/' for URI::FTP
        if (new_url.scheme == 'ftp' && !path.start_with?('/'))
          path.insert(0,'/')
        end

        # make sure the path does not contain any .. or . directories,
        # since URI::Generic#merge cannot normalize paths such as
        # "/stuff/../"
        new_url.path = URI.expand_path(path)
      end

      return new_url
    end
def to_absolute(link)
      link    = link.to_s
      new_url = begin
                  url.merge(link)
                rescue Exception
                  return
                end

      if (!new_url.opaque) && (path = new_url.path)
        # ensure that paths begin with a leading '/' for URI::FTP
        if (new_url.scheme == 'ftp' && !path.start_with?('/'))
          path.insert(0,'/')
        end

        # make sure the path does not contain any .. or . directories,
        # since URI::Generic#merge cannot normalize paths such as
        # "/stuff/../"
        new_url.path = URI.expand_path(path)
      end

      return new_url
    end
def to_absolute ( link ) link = link . to_s new_url = begin url . merge ( link ) rescue Exception return end if ( ! new_url . opaque ) && ( path = new_url . path ) # ensure that paths begin with a leading '/' for URI::FTP if ( new_url . scheme == 'ftp' && ! path . start_with? ( '/' ) ) path . insert ( 0 , '/' ) end # make sure the path does not contain any .. or . directories, # since URI::Generic#merge cannot normalize paths such as # "/stuff/../" new_url . path = URI . expand_path ( path ) end return new_url end
Normalizes and expands a given link into a proper URI.

 @param [String] link
   The link to normalize and expand.

 @return [URI::HTTP]
   The normalized URI.
Normalizes and expands a given link into a proper URI .