diff --git a/lib/customer_fwd.rb b/lib/customer_fwd.rb index bee076d3acf7b65b6fdd6cd618d364a6a366981f..22a83c68685f64585e0a0436db9662d178909ea1 100644 --- a/lib/customer_fwd.rb +++ b/lib/customer_fwd.rb @@ -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 diff --git a/test/test_customer_fwd.rb b/test/test_customer_fwd.rb index 440985344ca25e8942537b054be332fa2aefb8be..3751364685fa465b8244ae1ae3ac7e8c3ea4f792 100644 --- a/test/test_customer_fwd.rb +++ b/test/test_customer_fwd.rb @@ -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