Replace base_uri with base_path (#10879)

DEV: Replace instances of Discourse.base_uri with Discourse.base_path

This is clearer because the base_uri is actually just a path prefix. This continues the work started in 555f467.
This commit is contained in:
Daniel Waterworth
2020-10-09 12:51:24 +01:00
committed by GitHub
parent 5e3130ac26
commit 721ee36425
34 changed files with 74 additions and 70 deletions

View File

@@ -380,10 +380,15 @@ module Discourse
SiteSetting.force_hostname.presence || RailsMultisite::ConnectionManagement.current_hostname
end
def self.base_uri(default_value = "")
def self.base_path(default_value = "")
ActionController::Base.config.relative_url_root.presence || default_value
end
def self.base_uri(default_value = "")
deprecate("Discourse.base_uri is deprecated, use Discourse.base_path instead")
base_path(default_value)
end
def self.base_protocol
SiteSetting.force_https? ? "https" : "http"
end
@@ -401,7 +406,7 @@ module Discourse
end
def self.base_url
base_url_no_prefix + base_uri
base_url_no_prefix + base_path
end
def self.route_for(uri)
@@ -415,8 +420,8 @@ module Discourse
return unless uri
path = +(uri.path || "")
if !uri.host || (uri.host == Discourse.current_hostname && path.start_with?(Discourse.base_uri))
path.slice!(Discourse.base_uri)
if !uri.host || (uri.host == Discourse.current_hostname && path.start_with?(Discourse.base_path))
path.slice!(Discourse.base_path)
return Rails.application.routes.recognize_path(path)
end
@@ -426,7 +431,6 @@ module Discourse
end
class << self
alias_method :base_path, :base_uri
alias_method :base_url_no_path, :base_url_no_prefix
end