Sha256: 480ed8a7cf7515d1b900a48bf6937339fd111224c7283c7d6517690439fefe18

Contents?: true

Size: 805 Bytes

Versions: 91

Compression:

Stored size: 805 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The slash_path_empty plugin considers "/" as an empty path,
    # in addition to the default of "" being considered an empty
    # path.  This makes it so +r.is+ without an argument will match
    # a path of "/", and +r.is+ and verb methods such as +r.get+ and
    # +r.post+ will match if the path is "/" after the arguments
    # are processed.  This can make it easier to handle applications
    # where a trailing "/" in the path should be ignored.
    module SlashPathEmpty
      module RequestMethods
        private

        # Consider the path empty if it is "/".
        def empty_path?
          super || remaining_path == '/'
        end
      end
    end

    register_plugin(:slash_path_empty, SlashPathEmpty)
  end
end

Version data entries

91 entries across 91 versions & 1 rubygems

Version Path
roda-3.29.0 lib/roda/plugins/slash_path_empty.rb
roda-3.28.0 lib/roda/plugins/slash_path_empty.rb
roda-3.27.0 lib/roda/plugins/slash_path_empty.rb
roda-3.26.0 lib/roda/plugins/slash_path_empty.rb
roda-3.25.0 lib/roda/plugins/slash_path_empty.rb
roda-3.24.0 lib/roda/plugins/slash_path_empty.rb
roda-3.23.0 lib/roda/plugins/slash_path_empty.rb
roda-3.22.0 lib/roda/plugins/slash_path_empty.rb
roda-3.21.0 lib/roda/plugins/slash_path_empty.rb
roda-3.20.0 lib/roda/plugins/slash_path_empty.rb
roda-3.19.0 lib/roda/plugins/slash_path_empty.rb
roda-3.18.0 lib/roda/plugins/slash_path_empty.rb
roda-3.17.0 lib/roda/plugins/slash_path_empty.rb
roda-3.16.0 lib/roda/plugins/slash_path_empty.rb
roda-3.15.0 lib/roda/plugins/slash_path_empty.rb
roda-3.14.1 lib/roda/plugins/slash_path_empty.rb
roda-3.14.0 lib/roda/plugins/slash_path_empty.rb
roda-3.13.0 lib/roda/plugins/slash_path_empty.rb
roda-3.12.0 lib/roda/plugins/slash_path_empty.rb
roda-3.11.0 lib/roda/plugins/slash_path_empty.rb