mirror of https://github.com/rails/rails
Allow setting config.hosts to nil
Prior to #46858, uses can set `config.hosts = nil` to allow all hosts. But now it causes `NoMethodError` because the check uses only `empty?`. Given that the HostAuthorization itself allows taking `nil` as hosts, I think this breaking change is not intentional. Therefore this commit fixes the issue by also checking if the value is `nil`.
This commit is contained in:
parent
481c169aa5
commit
56ecea0d4d
|
@ -13,7 +13,7 @@ module Rails
|
|||
|
||||
def build_stack
|
||||
ActionDispatch::MiddlewareStack.new do |middleware|
|
||||
unless config.hosts.empty?
|
||||
unless config.hosts.nil? || config.hosts.empty?
|
||||
middleware.use ::ActionDispatch::HostAuthorization, config.hosts, **config.host_authorization
|
||||
end
|
||||
|
||||
|
|
|
@ -154,6 +154,13 @@ module ApplicationTests
|
|||
assert_not_includes middleware, "ActionDispatch::HostAuthorization"
|
||||
end
|
||||
|
||||
test "ActionDispatch::HostAuthorization is not included if hosts is set to nil" do
|
||||
add_to_config "config.hosts = nil"
|
||||
boot!
|
||||
|
||||
assert_not_includes middleware, "ActionDispatch::HostAuthorization"
|
||||
end
|
||||
|
||||
test "Rack::Cache is not included by default" do
|
||||
boot!
|
||||
|
||||
|
|
Loading…
Reference in New Issue