Sha256: d088f4a2358acbf22db5675a04fc3b65e66df9fe709e8075d36e4a6c888e0f79

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

class Usher
  class Node
    class RootIgnoringTrailingDelimiters < Root

      alias_method :lookup_without_stripping, :lookup
    
      def initialize(route_set, request_methods)
        super
        @stripper = /#{Regexp.quote(route_set.delimiters.first)}$/
      end
    
      def lookup(request_object, path)
        if path.size > 1
          new_path = path.gsub(@stripper, '')
          response = lookup_without_stripping(request_object, new_path)
          response.only_trailing_delimiters = (new_path.size != path.size) if response
          response
        else
          lookup_without_stripping(request_object, path)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
usher-0.7.5 lib/usher/node/root_ignoring_trailing_delimiters.rb
usher-0.7.4 lib/usher/node/root_ignoring_trailing_delimiters.rb
usher-0.7.3 lib/usher/node/root_ignoring_trailing_delimiters.rb