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