From 0e62b91afefad6ed8635c330ef0df24e767ac113 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 30 May 2022 21:40:09 -0500 Subject: [PATCH] Empty URI is invalid --- lib/customer_fwd.rb | 2 +- test/test_customer_fwd.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/customer_fwd.rb b/lib/customer_fwd.rb index bee076d..22a83c6 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 4409853..3751364 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 -- 2.45.2