diff options
Diffstat (limited to 'lib/chef/http/basic_client.rb')
-rw-r--r-- | lib/chef/http/basic_client.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/chef/http/basic_client.rb b/lib/chef/http/basic_client.rb index 076d152d16..de5e7c03a8 100644 --- a/lib/chef/http/basic_client.rb +++ b/lib/chef/http/basic_client.rb @@ -101,12 +101,16 @@ class Chef env["#{url.scheme.upcase}_PROXY"] || env["#{url.scheme}_proxy"] # Check if the proxy string contains a scheme. If not, add the url's scheme to the - # proxy before parsing. The regex /^.*:\/\// matches, for example, http://. - proxy = if proxy.match(/^.*:\/\//) - URI.parse(proxy) - else - URI.parse("#{url.scheme}://#{proxy}") - end if String === proxy + # proxy before parsing. The regex /^.*:\/\// matches, for example, http://. Reusing proxy + # here since we are really just trying to get the string built correctly. + if String === proxy && !proxy.strip.empty? + if proxy.match(/^.*:\/\//) + proxy = URI.parse(proxy.strip) + else + proxy = URI.parse("#{url.scheme}://#{proxy.strip}") + end + end + no_proxy = Chef::Config[:no_proxy] || env['NO_PROXY'] || env['no_proxy'] excludes = no_proxy.to_s.split(/\s*,\s*/).compact excludes = excludes.map { |exclude| exclude =~ /:\d+$/ ? exclude : "#{exclude}:*" } |