Sha256: 6afa6da12578dee6bf21116e42f41f1ac8ea4ac28b1f13d09b1b43a2da87c35e

Contents?: true

Size: 1.28 KB

Versions: 266

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Bundler
  module URICredentialsFilter
    module_function

    def credential_filtered_uri(uri_to_anonymize)
      return uri_to_anonymize if uri_to_anonymize.nil?
      uri = uri_to_anonymize.dup
      if uri.is_a?(String)
        return uri if File.exist?(uri)

        require_relative "vendored_uri"
        uri = Bundler::URI(uri)
      end

      if uri.userinfo
        # oauth authentication
        if uri.password == "x-oauth-basic" || uri.password == "x"
          # URI as string does not display with password if no user is set
          oauth_designation = uri.password
          uri.user = oauth_designation
        end
        uri.password = nil
      end
      return uri.to_s if uri_to_anonymize.is_a?(String)
      uri
    rescue Bundler::URI::InvalidURIError # uri is not canonical uri scheme
      uri
    end

    def credential_filtered_string(str_to_filter, uri)
      return str_to_filter if uri.nil? || str_to_filter.nil?
      str_with_no_credentials = str_to_filter.dup
      anonymous_uri_str = credential_filtered_uri(uri).to_s
      uri_str = uri.to_s
      if anonymous_uri_str != uri_str
        str_with_no_credentials = str_with_no_credentials.gsub(uri_str, anonymous_uri_str)
      end
      str_with_no_credentials
    end
  end
end

Version data entries

266 entries across 266 versions & 7 rubygems

Version Path
harbr-0.1.60 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.59 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.58 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.57 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.54 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.53 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.52 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.47 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb
harbr-0.1.39 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/uri_credentials_filter.rb