diff --git a/lib/final_destination.rb b/lib/final_destination.rb index c2a89c54ae1..a009c204b07 100644 --- a/lib/final_destination.rb +++ b/lib/final_destination.rb @@ -10,7 +10,12 @@ class FinalDestination attr_reader :cookie def initialize(url, opts=nil) - @uri = URI(url) rescue nil + @uri = + begin + URI(url) if url + rescue URI::InvalidURIError + end + @opts = opts || {} @opts[:max_redirects] ||= 5 @opts[:lookup_ip] ||= lambda do |host|