Module: Rack::Utils

Defined in:
lib/rack/utils_monkey_patch.rb

Instance Method Summary collapse

Instance Method Details

#escape(s) ⇒ Object


3
4
5
6
7
# File 'lib/rack/utils_monkey_patch.rb', line 3

def escape(s)
  s.to_s.dup.force_encoding("utf-8").gsub(/([^ a-zA-Z0-9_.-]+)/u) {
    '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
  }.tr(' ', '+')
end