From f366325b3ba596989ce45f55d36bed8ac6409de3 Mon Sep 17 00:00:00 2001 From: Karl Freeman Date: Mon, 17 Feb 2014 09:28:57 +0000 Subject: [PATCH] return localhost when host is 0.0.0.0 #1011 --- .../lib/middleman-core/preview_server.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index 42730788..5ad4bb72 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -21,9 +21,8 @@ module Middleman @options = opts mount_instance(new_app) - scheme = https? ? 'https' : 'http' - logger.info "== The Middleman is standing watch at #{scheme}://#{host}:#{port}" - logger.info "== Inspect your site configuration at #{scheme}://#{host}:#{port}/__middleman/" + logger.info "== The Middleman is standing watch at #{uri}" + logger.info "== Inspect your site configuration at #{uri + '__middleman'}" @initialized ||= false return if @initialized @@ -264,6 +263,15 @@ module Middleman end end end + + # Returns the URI the preview server will run on + # @return [URI] + def uri + host = @host.eql?('0.0.0.0') ? 'localhost' : @host + scheme = https? ? 'https' : 'http' + URI("#{scheme}://#{host}:#{@port}") + end + end class FilteredWebrickLog < ::WEBrick::Log