module Bundler::URI
def self.encode_www_form(enum, enc=nil)
#=> "q=ruby&q=perl&lang=en"
Bundler::URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
#=> "q=ruby&q=perl&lang=en"
Bundler::URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
#=> "q=ruby&lang=en"
Bundler::URI.encode_www_form("q" => "ruby", "lang" => "en")
#=> "q=ruby&lang=en"
Bundler::URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
This refers https://url.spec.whatwg.org/#concept-urlencoded-serializer
multipart/form-data.
This method doesn't handle files. When you send a file, use
ASCII incompatible encoding are converted to UTF-8.)
encoding or mixed encoding data. (Strings which are encoded in an HTML5
before calling this method if you want to send data as other than original
This method doesn't convert the encoding of given items, so convert them
This internally uses Bundler::URI.encode_www_form_component(str).
from given an Enumerable object.
This generates application/x-www-form-urlencoded data defined in HTML5
Generates URL-encoded form data from given +enum+.
def self.encode_www_form(enum, enc=nil) enum.map do |k,v| if v.nil? encode_www_form_component(k, enc) elsif v.respond_to?(:to_ary) v.to_ary.map do |w| str = encode_www_form_component(k, enc) unless w.nil? str << '=' str << encode_www_form_component(w, enc) end end.join('&') else str = encode_www_form_component(k, enc) str << '=' str << encode_www_form_component(v, enc) end end.join('&') end