mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Change the index
arg of ActionDispatch::Static#new
to a kwarg
This commit is contained in:
parent
96bb004fc6
commit
a888c3cdc9
3 changed files with 5 additions and 6 deletions
|
@ -13,7 +13,7 @@ module ActionDispatch
|
|||
# located at `public/assets/application.js` if the file exists. If the file
|
||||
# does not exist, a 404 "File not Found" response will be returned.
|
||||
class FileHandler
|
||||
def initialize(root, cache_control, index = 'index')
|
||||
def initialize(root, cache_control, index: 'index')
|
||||
@root = root.chomp('/')
|
||||
@compiled_root = /^#{Regexp.escape(root)}/
|
||||
headers = cache_control && { 'Cache-Control' => cache_control }
|
||||
|
@ -21,7 +21,6 @@ module ActionDispatch
|
|||
@index = index
|
||||
end
|
||||
|
||||
|
||||
# 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.
|
||||
|
@ -105,9 +104,9 @@ module ActionDispatch
|
|||
# produce a directory traversal using this middleware. Only 'GET' and 'HEAD'
|
||||
# requests will result in a file being returned.
|
||||
class Static
|
||||
def initialize(app, path, cache_control = nil, index = 'index')
|
||||
def initialize(app, path, cache_control = nil, index: 'index')
|
||||
@app = app
|
||||
@file_handler = FileHandler.new(path, cache_control, index)
|
||||
@file_handler = FileHandler.new(path, cache_control, index: index)
|
||||
end
|
||||
|
||||
def call(env)
|
||||
|
|
|
@ -263,7 +263,7 @@ class StaticTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_non_default_static_index
|
||||
@app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60", "other-index")
|
||||
@app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60", index: "other-index")
|
||||
assert_html "/other-index.html", get("/other-index.html")
|
||||
assert_html "/other-index.html", get("/other-index")
|
||||
assert_html "/other-index.html", get("/")
|
||||
|
|
|
@ -18,7 +18,7 @@ module Rails
|
|||
middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
|
||||
|
||||
if config.serve_static_files
|
||||
middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control, config.static_index
|
||||
middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control, index: config.static_index
|
||||
end
|
||||
|
||||
if rack_cache = load_rack_cache
|
||||
|
|
Loading…
Reference in a new issue