diff --git a/lib/uri/common.rb b/lib/uri/common.rb index 971a684..57708e2 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -575,6 +575,7 @@ def self.encode_www_form(enum, enc=nil) str << '=' str << encode_www_form_component(w, enc) end + str end.join('&') else str = encode_www_form_component(k, enc) diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 5692640..98098bb 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -17,6 +17,11 @@ class Foo end end + + def test_encode_www_form_preserves_nil_array_values + assert_equal("foo&foo=a&foo", URI.encode_www_form(foo: [nil, "a", nil])) + end + def test_fallback_constants EnvUtil.suppress_warning do assert_raise(NameError) { URI::FOO }