mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:41:31 +08:00
fix very wonky logic around hostname calculation
This commit is contained in:
parent
160567e372
commit
2e87974cb5
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user