Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
Added OverSIP::SIP::Uri#clean_params() (fix #36).
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Feb 5, 2013
1 parent 28a996c commit 31114a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/oversip/sip/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions test/test_uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 31114a0

Please sign in to comment.