From 089a1bd3be270faf883fd126b304b80b1e0b2f8a Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 18 Jul 2017 09:50:06 +0900 Subject: [PATCH] Specify the error that we want to ignore instead of rescuing all errors. --- lib/final_destination.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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|