Fix #3500: Redirect API endpoints with md5 query param to correct format.

This commit is contained in:
evazion
2018-01-14 20:36:57 -06:00
parent 1a7bfca9bd
commit 7a0fb0f5d3

View File

@@ -6,7 +6,9 @@ class PostsController < ApplicationController
def index
if params[:md5].present?
@post = Post.find_by_md5(params[:md5])
redirect_to post_path(@post)
respond_with(@post) do |format|
format.html { redirect_to(@post) }
end
else
limit = params[:limit] || (params[:tags] =~ /(?:^|\s)limit:(\d+)(?:$|\s)/ && $1) || CurrentUser.user.per_page
@random = params[:random] || params[:tags] =~ /(?:^|\s)order:random(?:$|\s)/