Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert Commands::Serve#server_address signature change. #5456

Merged
merged 2 commits into from Oct 6, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 14 additions & 9 deletions lib/jekyll/commands/serve.rb
Expand Up @@ -104,12 +104,7 @@ def webrick_opts(opts)
def start_up_webrick(opts, destination)
server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
Jekyll.logger.info "Server address:", server_address(
server.config[:SSLEnable],
server.config[:BindAddress],
server.config[:Port],
opts["baseurl"]
)
Jekyll.logger.info "Server address:", server_address(server, opts)
launch_browser server, opts if opts["open_url"]
boot_or_detach server, opts
end
Expand All @@ -129,9 +124,19 @@ def file_handler_opts
#

private
def server_address(prefix, address, port, baseurl = nil)
def server_address(server, options = {})
format_url(
server.config[:SSLEnable],
server.config[:BindAddress],
server.config[:Port],
options["baseurl"],
)
end

private
def format_url(ssl_enabled, address, port, baseurl = nil)
format("%{prefix}://%{address}:%{port}%{baseurl}", {
:prefix => prefix ? "https" : "http",
:prefix => ssl_enabled ? "https" : "http",
:address => address,
:port => port,
:baseurl => baseurl ? "#{baseurl}/" : ""
Expand All @@ -143,7 +148,7 @@ def server_address(prefix, address, port, baseurl = nil)
private
def default_url(opts)
config = configuration_from_options(opts)
server_address(
format_url(
config["ssl_cert"] && config["ssl_key"],
config["host"] == "127.0.0.1" ? "localhost" : config["host"],
config["port"]
Expand Down