Module: Rack::Utils
- Defined in:
- lib/usher/util/rack-mixins.rb,
lib/usher/util/rack-mixins.rb,
lib/usher/util/rack-mixins.rb
Class Method Summary collapse
Class Method Details
.uri_escape(s) ⇒ Object
6 7 8 9 10 |
# File 'lib/usher/util/rack-mixins.rb', line 6 def uri_escape(s) s.to_s.gsub(/([^:\/?\[\]\-_~\.!\$&'\(\)\*\+,;=@a-zA-Z0-9]+)/n) { '%'<<$1.unpack('H2'*$1.size).join('%').upcase } end |
.uri_escape!(s) ⇒ Object
19 20 21 22 23 |
# File 'lib/usher/util/rack-mixins.rb', line 19 def uri_escape!(s) s.to_s.gsub!(/([^:\/?\[\]\-_~\.!\$&'\(\)\*\+,;=@a-zA-Z0-9]+)/n) { '%'<<$1.unpack('H2'*$1.size).join('%').upcase } end |
.uri_unescape(s) ⇒ Object
32 33 34 35 36 |
# File 'lib/usher/util/rack-mixins.rb', line 32 def uri_unescape(s) gsub(/((?:%[0-9a-fA-F]{2})+)/n){ [$1.delete('%')].pack('H*') } end |