Sha256: 59447b6d11980710691c77a5c647a478e8bc03d8925974ef2d095d8fcfb12af6

Contents?: true

Size: 748 Bytes

Versions: 72

Compression:

Stored size: 748 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The unescape_path plugin decodes a URL-encoded path
    # before routing.  This fixes routing when the slashes
    # are URL-encoded as %2f and returns decoded parameters
    # when matched by symbols or regexps.
    #
    #   plugin :unescape_path
    #
    #   route do |r|
    #     # Assume /b/a URL encoded at %2f%62%2f%61
    #     r.on :x, /(.)/ do |*x|
    #       # x => ['b', 'a']
    #     end
    #   end
    module UnescapePath
      module RequestMethods
        private

        # Unescape the path.
        def _remaining_path(env)
          Rack::Utils.unescape(super)
        end
      end
    end

    register_plugin(:unescape_path, UnescapePath)
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
roda-3.55.0 lib/roda/plugins/unescape_path.rb
roda-3.54.0 lib/roda/plugins/unescape_path.rb
roda-3.53.0 lib/roda/plugins/unescape_path.rb
roda-3.52.0 lib/roda/plugins/unescape_path.rb
roda-3.51.0 lib/roda/plugins/unescape_path.rb
roda-3.50.0 lib/roda/plugins/unescape_path.rb
roda-3.49.0 lib/roda/plugins/unescape_path.rb
roda-3.48.0 lib/roda/plugins/unescape_path.rb
roda-3.47.0 lib/roda/plugins/unescape_path.rb
roda-3.46.0 lib/roda/plugins/unescape_path.rb
roda-3.45.0 lib/roda/plugins/unescape_path.rb
roda-3.44.0 lib/roda/plugins/unescape_path.rb
roda-3.43.1 lib/roda/plugins/unescape_path.rb
roda-3.43.0 lib/roda/plugins/unescape_path.rb
roda-3.42.0 lib/roda/plugins/unescape_path.rb
roda-3.41.0 lib/roda/plugins/unescape_path.rb
roda-3.40.0 lib/roda/plugins/unescape_path.rb
roda-3.39.0 lib/roda/plugins/unescape_path.rb
roda-3.38.0 lib/roda/plugins/unescape_path.rb
roda-3.37.0 lib/roda/plugins/unescape_path.rb