M lib/customer_fwd.rb => lib/customer_fwd.rb +1 -1
@@ 13,7 13,7 @@ class CustomerFwd
uri = "xmpp:#{$1.gsub(/%([0-9A-F]{2})/i) { $1.to_i(16).chr }}"
end
- URIS.fetch(uri.split(":", 2).first.to_sym) {
+ URIS.fetch(uri.split(":", 2).first&.to_sym) {
raise "Unknown forward URI: #{uri}"
}.new(uri: uri, timeout: timeout)
end
M test/test_customer_fwd.rb => test/test_customer_fwd.rb +6 -0
@@ 59,4 59,10 @@ class CustomerFwdTest < Minitest::Test
CustomerFwd.for(uri: "bogus:#{bogus}", timeout: 10)
end
end
+
+ def test_for_empty
+ assert_raises(RuntimeError) do
+ CustomerFwd.for(uri: "", timeout: 10)
+ end
+ end
end