lib/spidr/auth_store.rb
def [](url)
      # normalize the url
      url = URI(url)

      key = [url.scheme, url.host, url.port]
      paths = @credentials[key]

      return nil unless paths

      # longest path first
      ordered_paths = paths.keys.sort_by { |path_key| -path_key.length }

      # directories of the path
      path_dirs = URI.expand_path(url.path).split('/')

      ordered_paths.each do |path|
        return paths[path] if path_dirs[0,path.length] == path
      end

      return nil
    end
def [](url)
      # normalize the url
      url = URI(url)

      key = [url.scheme, url.host, url.port]
      paths = @credentials[key]

      return nil unless paths

      # longest path first
      ordered_paths = paths.keys.sort_by { |path_key| -path_key.length }

      # directories of the path
      path_dirs = URI.expand_path(url.path).split('/')

      ordered_paths.each do |path|
        return paths[path] if path_dirs[0,path.length] == path
      end

      return nil
    end
Creates a new auth store.

 @since 0.2.2


 Given a URL, return the most specific matching auth credential.

 @param [URI] url
   A fully qualified url including optional path.

 @return [AuthCredential, nil]
   Closest matching {AuthCredential} values for the URL,
   or `nil` if nothing matches.

 @since 0.2.2