fix very wonky logic around hostname calculation

This commit is contained in:
Sam 2013-05-31 08:48:34 +10:00
parent 160567e372
commit 2e87974cb5

View File

@ -20,7 +20,11 @@ module Discourse
# Get the current base URL for the current site
def self.current_hostname
RailsMultisite::ConnectionManagement.current_hostname
if SiteSetting.force_hostname.present?
SiteSetting.force_hostname
else
RailsMultisite::ConnectionManagement.current_hostname
end
end
def self.base_uri default_value=""
@ -32,14 +36,19 @@ module Discourse
end
def self.base_url_no_prefix
default_port = 80
protocol = "http"
protocol = "https" if SiteSetting.use_ssl?
if SiteSetting.force_hostname.present?
result = "#{protocol}://#{SiteSetting.force_hostname}"
else
result = "#{protocol}://#{current_hostname}"
if SiteSetting.use_ssl?
protocol = "https"
default_port = 443
end
result << ":#{SiteSetting.port}" if SiteSetting.port.present? && SiteSetting.port.to_i > 0
result = "#{protocol}://#{current_hostname}"
port = SiteSetting.port.present? && SiteSetting.port.to_i > 0 ? SiteSetting.port.to_i : default_port
result << ":#{SiteSetting.port}" if port != default_port
result
end