diff --git a/lib/oversip/sip/uri.rb b/lib/oversip/sip/uri.rb index 532e50c..7eb6929 100644 --- a/lib/oversip/sip/uri.rb +++ b/lib/oversip/sip/uri.rb @@ -98,6 +98,16 @@ def del_param k false end + def clean_params + return nil if unknown_scheme? + return false unless @params + @params.clear + @transport_param = nil + @phone_context_param = nil + @uri_modified = true + true + end + def transport_param= value return nil unless @scheme == :sip or @scheme == :sips if value diff --git a/test/test_uri.rb b/test/test_uri.rb index 1b8dd4d..42732d4 100644 --- a/test/test_uri.rb +++ b/test/test_uri.rb @@ -22,6 +22,11 @@ def test_sip_uri assert_equal "123", uri.get_param("Foo") assert_equal aor, uri.aor assert_equal full_uri, uri.to_s + + uri.clean_params + + assert_equal({}, uri.params) + assert_equal "sips:i%C3%B1aki@aliax.net:5060?X-Header-1=qwe&X-Header-2=asd", uri.to_s end def test_tel_uri @@ -39,6 +44,11 @@ def test_tel_uri assert_equal "bar", uri.get_param("Foo") assert_equal aor, uri.aor assert_equal full_uri, uri.to_s + + uri.clean_params + + assert_equal({}, uri.params) + assert_equal aor, uri.to_s end def test_http_uri @@ -53,5 +63,6 @@ def test_http_uri assert_true uri.unknown_scheme? assert_nil uri.aor assert_equal full_uri, uri.to_s + assert_nil uri.clean_params end end