Sha256: de78b3bd71b68a06872ea82c57d042e819a9b0b4b3871f3c12909274f9f93a91

Contents?: true

Size: 833 Bytes

Versions: 17

Compression:

Stored size: 833 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
      SLASH = "/".freeze

      module RequestMethods
        private

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

    register_plugin(:slash_path_empty, SlashPathEmpty)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
roda-2.27.0 lib/roda/plugins/slash_path_empty.rb
roda-2.26.0 lib/roda/plugins/slash_path_empty.rb
roda-2.25.0 lib/roda/plugins/slash_path_empty.rb
roda-2.24.0 lib/roda/plugins/slash_path_empty.rb
roda-2.23.0 lib/roda/plugins/slash_path_empty.rb
roda-2.22.0 lib/roda/plugins/slash_path_empty.rb
roda-2.21.0 lib/roda/plugins/slash_path_empty.rb
roda-2.20.0 lib/roda/plugins/slash_path_empty.rb
roda-2.19.0 lib/roda/plugins/slash_path_empty.rb
roda-2.18.0 lib/roda/plugins/slash_path_empty.rb
roda-2.17.0 lib/roda/plugins/slash_path_empty.rb
roda-2.16.0 lib/roda/plugins/slash_path_empty.rb
roda-2.15.0 lib/roda/plugins/slash_path_empty.rb
roda-2.14.0 lib/roda/plugins/slash_path_empty.rb
roda-2.13.0 lib/roda/plugins/slash_path_empty.rb
roda-2.12.0 lib/roda/plugins/slash_path_empty.rb
roda-2.11.0 lib/roda/plugins/slash_path_empty.rb