Sha256: a5ed9ae14bd844b6d054c082a89693e9de20f0a705b6abc04426f731f0f1a4c5
Contents?: true
Size: 877 Bytes
Versions: 11
Compression:
Stored size: 877 Bytes
Contents
require 'rack' unless Rack::Utils.respond_to?(:uri_escape) module Rack module Utils def uri_escape(s) s.to_s.gsub(/([^:\/?\[\]\-_~\.!\$&'\(\)\*\+,;=@a-zA-Z0-9]+)/n) { '%'<<$1.unpack('H2'*$1.size).join('%').upcase } end module_function :uri_escape end end end unless Rack::Utils.respond_to?(:uri_escape!) module Rack module Utils def uri_escape!(s) s.to_s.gsub!(/([^:\/?\[\]\-_~\.!\$&'\(\)\*\+,;=@a-zA-Z0-9]+)/n) { '%'<<$1.unpack('H2'*$1.size).join('%').upcase } end module_function :uri_escape! end end end unless Rack::Utils.respond_to?(:uri_unescape) module Rack module Utils def uri_unescape(s) gsub(/((?:%[0-9a-fA-F]{2})+)/n){ [$1.delete('%')].pack('H*') } end module_function :uri_unescape end end end
Version data entries
11 entries across 11 versions & 1 rubygems