checking whether the field location_uri.host is nil

This commit is contained in:
Thomas Röggla 2018-07-12 15:49:26 +02:00
parent 1f99da7a11
commit 2613d620fd
1 changed files with 11 additions and 8 deletions

View File

@ -107,16 +107,19 @@ module Vagrant
if progress_data.include?("Location") if progress_data.include?("Location")
location = progress_data.scan(/Location: (.+?)$/m).flatten.compact.first.to_s.strip location = progress_data.scan(/Location: (.+?)$/m).flatten.compact.first.to_s.strip
if !location.empty? if !location.empty?
@logger.info("download redirected to #{location}")
location_uri = URI.parse(location) location_uri = URI.parse(location)
source_uri = URI.parse(source)
source_host = source_uri.host.split(".", 2).last unless location_uri.host.nil?
location_host = location_uri.host.split(".", 2).last @logger.info("download redirected to #{location}")
if !@redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host) source_uri = URI.parse(source)
@ui.clear_line source_host = source_uri.host.split(".", 2).last
@ui.detail "Download redirected to host: #{location_uri.host}" location_host = location_uri.host.split(".", 2).last
if !@redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host)
@ui.clear_line
@ui.detail "Download redirected to host: #{location_uri.host}"
end
@redirect_notify = true
end end
@redirect_notify = true
end end
progress_data.replace("") progress_data.replace("")
break break