instance method match?

Ruby on Rails 5.2.8.1

Since v3.1.12 Last seen in v6.0.6

Available in: v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6

Signature

match?(path)

Takes a path to a file. If the file is found, has valid encoding, and has correct read permissions, the return value is a URI-escaped string representing the filename. Otherwise, false is returned.

Used by the Static class to check the existence of a valid file in the server’s public/ directory (see Static#call).

Parameters

path req
Source
# File actionpack/lib/action_dispatch/middleware/static.rb, line 30
    def match?(path)
      path = ::Rack::Utils.unescape_path path
      return false unless ::Rack::Utils.valid_path? path
      path = ::Rack::Utils.clean_path_info path

      paths = [path, "#{path}#{ext}", "#{path}/#{@index}#{ext}"]

      if match = paths.detect { |p|
        path = File.join(@root, p.b)
        begin
          File.file?(path) && File.readable?(path)
        rescue SystemCallError
          false
        end

      }
        return ::Rack::Utils.escape_path(match).b
      end
    end

Defined in actionpack/lib/action_dispatch/middleware/static.rb line 30 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::FileHandler

Type at least 2 characters to search.

↑↓ navigate · open · esc close