aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb
blob: a21e98fa80e831d2d6ee8a16ea0d28d714efd9a0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                      
module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module CGI #:nodoc:
      module EscapeSkippingSlashes #:nodoc:
        def escape_skipping_slashes(str)
          str = str.join('/') if str.respond_to? :join
          str.gsub(/([^ \/a-zA-Z0-9_.-])/n) do
            "%#{$1.unpack('H2').first.upcase}"
          end.tr(' ', '+')
        end
      end
    end
  end
end