mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FIX: permalink redirects should work on tag paths
This commit is contained in:
@ -259,7 +259,7 @@ class ListController < ApplicationController
|
||||
parent_category_id = nil
|
||||
if parent_slug_or_id.present?
|
||||
parent_category_id = Category.query_parent_category(parent_slug_or_id)
|
||||
redirect_or_not_found and return if parent_category_id.blank? && !id
|
||||
permalink_redirect_or_not_found and return if parent_category_id.blank? && !id
|
||||
end
|
||||
|
||||
@category = Category.query_category(slug_or_id, parent_category_id)
|
||||
@ -270,7 +270,7 @@ class ListController < ApplicationController
|
||||
(redirect_to category.url, status: 301) && return if category
|
||||
end
|
||||
|
||||
redirect_or_not_found and return if !@category
|
||||
permalink_redirect_or_not_found and return if !@category
|
||||
|
||||
@description_meta = @category.description_text
|
||||
raise Discourse::NotFound unless guardian.can_see?(@category)
|
||||
@ -349,23 +349,4 @@ class ListController < ApplicationController
|
||||
periods
|
||||
end
|
||||
|
||||
def redirect_or_not_found
|
||||
url = request.fullpath
|
||||
permalink = Permalink.find_by_url(url)
|
||||
|
||||
if permalink.present?
|
||||
# permalink present, redirect to that URL
|
||||
if permalink.external_url
|
||||
redirect_to permalink.external_url, status: :moved_permanently
|
||||
elsif permalink.target_url
|
||||
redirect_to "#{Discourse::base_uri}#{permalink.target_url}", status: :moved_permanently
|
||||
else
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
else
|
||||
# redirect to 404
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user