Fix #4973: Wiki pages json index returns 404.

Fix regression introduced in 0db20e0ca. Setting `format: false` on the
wiki pages resource disabled format negotiation on all wiki page routes,
not just the show page, which meant /wiki_pages.json no longer worked.

The fix to monkey patch the internal Rails method that parses the file
extension from the URL, and have it ignore everything but the .html,
.json, .js, and .xml extensions. This is really hacky and may break in
future Rails releases.
This commit is contained in:
evazion
2022-01-22 16:52:20 -06:00
parent a4279ceff2
commit 90be15e0b5
4 changed files with 25 additions and 10 deletions

View File

@@ -30,15 +30,6 @@ class WikiPagesController < ApplicationController
end
def show
if params[:format].present?
request.format = params[:format]
elsif params[:id].ends_with?(".html", ".json", ".xml")
request.format = params[:id].split(".").last
params[:id].delete_suffix!(".#{request.format.symbol}")
else
request.format = "html"
end
@wiki_page, found_by = WikiPage.find_by_id_or_title(params[:id])
if request.format.html? && @wiki_page.blank? && found_by == :title