Sha256: 6879d9450e07aa4f7e399dfa4c1807395818184a0e6dd374f2096f19a825cded

Contents?: true

Size: 612 Bytes

Versions: 92

Compression:

Stored size: 612 Bytes

Contents

module Bundler
  class AnonymizableURI
    attr_reader :original_uri,
                :without_credentials

    def initialize(original_uri, fallback_auth = nil)
      @original_uri = apply_auth(original_uri, fallback_auth).freeze
      @without_credentials = remove_auth(@original_uri).freeze
    end

  private

    def apply_auth(uri, auth = nil)
      if auth && uri.userinfo.nil?
        uri = uri.dup
        uri.userinfo = auth
      end

      uri
    end

    def remove_auth(uri)
      if uri.userinfo
        uri = uri.dup
        uri.user = uri.password = nil
      end

      uri
    end

  end
end

Version data entries

92 entries across 64 versions & 4 rubygems

Version Path
bundler-1.9.1 lib/bundler/anonymizable_uri.rb
bundler-1.9.0 lib/bundler/anonymizable_uri.rb
bundler-1.9.0.pre.1 lib/bundler/anonymizable_uri.rb
bundler-1.9.0.rc lib/bundler/anonymizable_uri.rb
bundler-1.9.0.pre lib/bundler/anonymizable_uri.rb
bundler-1.8.5 lib/bundler/anonymizable_uri.rb
bundler-1.8.4 lib/bundler/anonymizable_uri.rb
bundler-1.8.3 lib/bundler/anonymizable_uri.rb
bundler-1.8.2 lib/bundler/anonymizable_uri.rb
bundler-1.8.1 lib/bundler/anonymizable_uri.rb
bundler-1.8.0 lib/bundler/anonymizable_uri.rb
bundler-1.8.0.pre lib/bundler/anonymizable_uri.rb