mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 20:08:26 +00:00
FIX: support for redirects to external url in permalinks table was broken
This commit is contained in:
parent
e17ea2e787
commit
ae028a5bb1
@ -3,11 +3,18 @@ class PermalinksController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
url = request.fullpath[1..-1]
|
url = request.fullpath[1..-1]
|
||||||
|
|
||||||
permalink = Permalink.find_by_url(url)
|
permalink = Permalink.find_by_url(url)
|
||||||
if permalink && permalink.target_url
|
|
||||||
|
raise Discourse::NotFound unless permalink
|
||||||
|
|
||||||
|
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
|
redirect_to "#{Discourse::base_uri}#{permalink.target_url}", status: :moved_permanently
|
||||||
else
|
else
|
||||||
raise Discourse::NotFound
|
raise Discourse::NotFound
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user