Sha256: 8c2bcd2d7083c5a247cecc4f325975861cd4cf85c2c0caf7c2d179ea46cb0ab8

Contents?: true

Size: 800 Bytes

Versions: 13

Compression:

Stored size: 800 Bytes

Contents

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

13 entries across 13 versions & 1 rubygems

Version Path
roda-2.9.0 lib/roda/plugins/slash_path_empty.rb
roda-2.8.0 lib/roda/plugins/slash_path_empty.rb
roda-2.7.0 lib/roda/plugins/slash_path_empty.rb
roda-2.6.0 lib/roda/plugins/slash_path_empty.rb
roda-2.5.1 lib/roda/plugins/slash_path_empty.rb
roda-2.5.0 lib/roda/plugins/slash_path_empty.rb
roda-2.4.0 lib/roda/plugins/slash_path_empty.rb
roda-2.3.0 lib/roda/plugins/slash_path_empty.rb
roda-2.2.0 lib/roda/plugins/slash_path_empty.rb
roda-2.1.0 lib/roda/plugins/slash_path_empty.rb
roda-2.0.0 lib/roda/plugins/slash_path_empty.rb
roda-1.3.0 lib/roda/plugins/slash_path_empty.rb
roda-1.2.0 lib/roda/plugins/slash_path_empty.rb