Sha256: 95fdb006a571b3437de7a203505a9f5c6d5d0db7bfaa261044a93d519821e41e

Contents?: true

Size: 497 Bytes

Versions: 7

Compression:

Stored size: 497 Bytes

Contents

# Override escape to use bytesize for multibyte char compatibility
# Use the unicode modifier when matching a UTF-8 String on Ruby >= 1.9
module Rack
  module Utils
    def escape(s)
      regexp = case
        when s.respond_to?(:encoding) && s.encoding === Encoding.find('UTF-8')
          /([^ a-zA-Z0-9_.-]+)/u
        else
          /([^ a-zA-Z0-9_.-]+)/n
        end
      s.to_s.gsub(regexp) {
        '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
      }.tr(' ', '+')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
openhood-sinatra_app_gen-0.0.1 lib/generators/sinatra_app/templates/lib/rack_fix.rb.erb
openhood-sinatra_app_gen-0.1.0 lib/generators/sinatra_app/templates/lib/rack_fix.rb.erb
openhood-sinatra_app_gen-0.1.1 lib/generators/sinatra_app/templates/lib/rack_fix.rb.erb
openhood-sinatra_app_gen-0.1.2 lib/generators/sinatra_app/templates/lib/rack_fix.rb.erb
openhood-sinatra_app_gen-0.1.3 lib/generators/sinatra_app/templates/lib/rack_fix.rb.erb
openhood-sinatra_app_gen-0.1.4 lib/generators/sinatra_app/templates/lib/rack_fix.rb.erb
openhood-sinatra_app_gen-0.1.5 lib/generators/sinatra_app/templates/lib/rack_fix.rb.erb