diff options
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/settings.rb | 7 | ||||
-rw-r--r-- | lib/bundler/uri_credentials_filter.rb | 9 |
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 |