Sha256: 2029f1d25580fedf0c0f9af788f7597465f89eea7c557c8ecf64f9c04770a1e3

Contents?: true

Size: 481 Bytes

Versions: 10

Compression:

Stored size: 481 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

      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

10 entries across 10 versions & 1 rubygems

Version Path
usher-0.6.6 lib/usher/util/rack-mixins.rb
usher-0.6.5 lib/usher/util/rack-mixins.rb
usher-0.6.4 lib/usher/util/rack-mixins.rb
usher-0.6.3 lib/usher/util/rack-mixins.rb
usher-0.6.2 lib/usher/util/rack-mixins.rb
usher-0.6.1 lib/usher/util/rack-mixins.rb
usher-0.6.0 lib/usher/util/rack-mixins.rb
usher-0.5.13 lib/usher/util/rack-mixins.rb
usher-0.5.12 lib/usher/util/rack-mixins.rb
usher-0.5.11 lib/usher/util/rack-mixins.rb