Class: X::CGI

Inherits:
Object
  • Object
show all
Defined in:
lib/x/cgi.rb

Class Method Summary collapse

Class Method Details

.escape(value) ⇒ Object

TODO: Replace CGI.escape with CGI.escapeURIComponent when support for Ruby 3.1 is dropped



6
7
8
# File 'lib/x/cgi.rb', line 6

def self.escape(value)
  ::CGI.escape(value).gsub("+", "%20")
end

.escape_params(params) ⇒ Object



10
11
12
# File 'lib/x/cgi.rb', line 10

def self.escape_params(params)
  params.map { |k, v| "#{k}=#{escape(v)}" }.join("&")
end