method
decode_www_form
Ruby latest stable (v2_5_5)
-
0 notes -
Class: URI
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (-38)
- 2_2_9 (0)
- 2_4_6 (4)
- 2_5_5 (0)
- 2_6_3 (1)
- What's this?
decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
public
Decode URL-encoded form data from given str.
This decodes application/x-www-form-urlencoded data and returns array of key-value array.
This refers http://url.spec.whatwg.org/#concept-urlencoded-parser , so this supports only &-separator, don’t support ;-separator.
ary = URI.decode_www_form("a=1&a=2&b=3") p ary #=> [['a', '1'], ['a', '2'], ['b', '3']] p ary.assoc('a').last #=> '1' p ary.assoc('b').last #=> '3' p ary.rassoc('a').last #=> '2' p Hash[ary] # => {"a"=>"2", "b"=>"3"}
See URI.decode_www_form_component, URI.encode_www_form