提交 d0accc23 编写于 作者: J Jon Moss

CLI arg "host" has precedence over ENV var "host"

This is a regression from when the server command switched to its own
argument parser, as opposed to Rack's. Rack's argument parser, when
provided with a "host" argument, gives that value precedence over
environment variables.
上级 88b16843
......@@ -188,10 +188,12 @@ def port
end
def host
unless (default_host = options[:binding])
if options[:binding]
options[:binding]
else
default_host = environment == "development" ? "localhost" : "0.0.0.0"
ENV.fetch("HOST", default_host)
end
ENV.fetch("HOST", default_host)
end
def environment
......
......@@ -139,6 +139,14 @@ def test_host
end
end
def test_argument_precedence_over_environment_variable
switch_env "HOST", "1.2.3.4" do
args = ["-b", "127.0.0.1"]
options = parse_arguments(args)
assert_equal "127.0.0.1", options[:Host]
end
end
def test_records_user_supplied_options
server_options = parse_arguments(["-p", 3001])
assert_equal [:Port], server_options[:user_supplied_options]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册