summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-12-06 13:30:29 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-12-08 14:11:51 +0100
commitbfa3d1e3966f497e916e90bd2f2f946662c77bf4 (patch)
treee52ab81d00172c3a9416f94233f50d7afe89e639
parentfd38d08caaaa5fa4b1a5ff8848ed55b843208f55 (diff)
downloadbundler-bfa3d1e3966f497e916e90bd2f2f946662c77bf4.tar.gz
Refactor stuff to not load URI if not needed
-rw-r--r--lib/bundler/settings.rb7
-rw-r--r--lib/bundler/uri_credentials_filter.rb9
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 241b921330..b9bbd7b952 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -150,8 +150,11 @@ module Bundler
end
def mirror_for(uri)
- require "uri"
- uri = URI(uri) unless uri.is_a?(URI)
+ if uri.is_a?(String)
+ require "uri"
+ uri = URI(uri)
+ end
+
gem_mirrors.for(uri.to_s).uri
end
diff --git a/lib/bundler/uri_credentials_filter.rb b/lib/bundler/uri_credentials_filter.rb
index e63d758e6c..455b4503ea 100644
--- a/lib/bundler/uri_credentials_filter.rb
+++ b/lib/bundler/uri_credentials_filter.rb
@@ -7,8 +7,11 @@ module Bundler
def credential_filtered_uri(uri_to_anonymize)
return uri_to_anonymize if uri_to_anonymize.nil?
uri = uri_to_anonymize.dup
- require "uri"
- uri = URI(uri) unless uri.is_a?(URI)
+ if uri.is_a?(String)
+ require "uri"
+ uri = URI(uri)
+ end
+
if uri.userinfo
# oauth authentication
if uri.password == "x-oauth-basic" || uri.password == "x"
@@ -18,8 +21,8 @@ module Bundler
end
uri.password = nil
end
- return uri if uri_to_anonymize.is_a?(URI)
return uri.to_s if uri_to_anonymize.is_a?(String)
+ uri
rescue URI::InvalidURIError # uri is not canonical uri scheme
uri
end