summaryrefslogtreecommitdiff
path: root/lib/rubygems/remote_fetcher.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2021-08-24 12:02:29 +0200
committerHiroshi SHIBATA <[email protected]>2021-08-31 19:06:14 +0900
commit1e290c31f4fdfd330b9cd1d5c7fe61efa4ab066c ()
tree0d3e58f3df45c7ab430375fe27550db6f6df6a65 /lib/rubygems/remote_fetcher.rb
parentf0c6cc14b10616a61d3113dd5a88291fe915461b (diff)
[rubygems/rubygems] Merge `Gem::UriParser` and `Gem::PrintableUri` into a `Gem::Uri` class
The new class is a wrapper on top of an URI. And then, when you want credentials redacted, you call `#redacted` that returns a copy of itself, but with credentials redacted. https://.com/rubygems/rubygems/commit/9581c2740a
Notes: Merged: https://.com/ruby/ruby/pull/4789
-rw-r--r--lib/rubygems/remote_fetcher.rb17
1 files changed, 8 insertions, 9 deletions
@@ -4,8 +4,7 @@ require_relative 'request'
require_relative 'request/connection_pools'
require_relative 's3_uri_signer'
require_relative 'uri_formatter'
-require_relative 'uri_parser'
-require_relative 'printable_uri'
require_relative 'user_interaction'
##
@@ -26,12 +25,12 @@ class Gem::RemoteFetcher
attr_accessor :uri, :original_uri
def initialize(message, uri)
- @original_uri = uri.dup
- uri = Gem::PrintableUri.parse_uri(uri)
- super(uri.valid_uri? && uri.original_password ? message.sub(uri.original_password, 'REDACTED') : message)
- @uri = uri.to_s
end
def to_s # :nodoc:
@@ -127,7 +126,7 @@ class Gem::RemoteFetcher
require "fileutils"
FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
- source_uri = Gem::UriParser.parse_uri(source_uri)
scheme = source_uri.scheme
@@ -222,7 +221,7 @@ class Gem::RemoteFetcher
unless location = response['Location']
raise FetchError.new("redirecting but no redirect location was given", uri)
end
- location = Gem::UriParser.parse_uri location
if https?(uri) && !https?(location)
raise FetchError.new("redirecting to non-https resource: #{location}", uri)
@@ -240,7 +239,7 @@ class Gem::RemoteFetcher
# Downloads +uri+ and returns it as a String.
def fetch_path(uri, mtime = nil, head = false)
- uri = Gem::UriParser.parse_uri uri
unless uri.scheme
raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}"