2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-08-28 15:09:36 -04:00
|
|
|
class PermalinksController < ApplicationController
|
2017-08-31 00:06:56 -04:00
|
|
|
skip_before_action :check_xhr, :preload_json
|
2014-08-28 15:09:36 -04:00
|
|
|
|
|
|
|
def show
|
2015-07-21 23:40:45 -04:00
|
|
|
url = request.fullpath
|
2015-04-23 16:45:28 -04:00
|
|
|
|
2014-09-10 13:58:52 -04:00
|
|
|
permalink = Permalink.find_by_url(url)
|
2015-04-23 16:45:28 -04:00
|
|
|
|
|
|
|
raise Discourse::NotFound unless permalink
|
|
|
|
|
2018-08-19 23:10:49 -04:00
|
|
|
if permalink.target_url
|
2015-10-12 16:48:32 -04:00
|
|
|
redirect_to permalink.target_url, status: :moved_permanently
|
2014-08-28 15:09:36 -04:00
|
|
|
else
|
|
|
|
raise Discourse::NotFound
|
|
|
|
end
|
|
|
|
end
|
2015-04-23 16:45:28 -04:00
|
|
|
|
2014-08-28 15:09:36 -04:00
|
|
|
end
|