Module: URI

Defined in:
lib/uri-extensions.rb

Class Method Summary collapse

Class Method Details

.escape_params(params) ⇒ Object

This returns a URL-encoded string suitable for use as a POST body or for pasting into a URL.



31
32
33
# File 'lib/uri-extensions.rb', line 31

def self.escape_params(params)
  escaped_params_array(params).join('&')
end

.escaped_params_array(params) ⇒ Object



25
26
27
# File 'lib/uri-extensions.rb', line 25

def self.escaped_params_array(params)
  params.map{|k,v| fully_escape(k.to_s) + '=' + fully_escape(v.to_s)}
end

.fully_escape(uri) ⇒ Object

Fully escape the web parameters



21
22
23
# File 'lib/uri-extensions.rb', line 21

def self.fully_escape(uri)
  self.escape(uri, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end