mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: All kinds of permalinks should return relative URLs
Mixing relative and absolute URLs is unnecessary and confusing.
This commit is contained in:
committed by
Gerhard Schlager
parent
4e80c9eb13
commit
387e906610
@@ -946,6 +946,8 @@ class Category < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
alias_method :relative_url, :url
|
||||
|
||||
# If the name changes, try and update the category definition topic too if it's an exact match
|
||||
def rename_category_definition
|
||||
return if topic.blank?
|
||||
|
||||
@@ -72,11 +72,11 @@ class Permalink < ActiveRecord::Base
|
||||
|
||||
def target_url
|
||||
return external_url if external_url
|
||||
return "#{Discourse.base_path}#{post.url}" if post
|
||||
return post.relative_url if post
|
||||
return topic.relative_url if topic
|
||||
return category.url if category
|
||||
return tag.full_url if tag
|
||||
return user.full_url if user
|
||||
return category.relative_url if category
|
||||
return tag.relative_url if tag
|
||||
return user.relative_url if user
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
@@ -210,6 +210,8 @@ class Tag < ActiveRecord::Base
|
||||
"#{Discourse.base_path}/tag/#{UrlHelper.encode_component(self.name)}"
|
||||
end
|
||||
|
||||
alias_method :relative_url, :url
|
||||
|
||||
def full_url
|
||||
"#{Discourse.base_url}/tag/#{UrlHelper.encode_component(self.name)}"
|
||||
end
|
||||
|
||||
@@ -1779,6 +1779,10 @@ class User < ActiveRecord::Base
|
||||
username_lower == User.normalize_username(another_username)
|
||||
end
|
||||
|
||||
def relative_url
|
||||
"#{Discourse.base_path}/u/#{encoded_username}"
|
||||
end
|
||||
|
||||
def full_url
|
||||
"#{Discourse.base_url}/u/#{encoded_username}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user