From 068d435f568890ba2264a5cd673ecfd444f35383 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 28 Nov 2022 17:05:58 -0600 Subject: [PATCH] controllers: fix index `redirect` param to not redirect to .html extension. Fix searches like this: * https://danbooru.donmai.u/wiki_pages?search[title]=touhou&redirect=true To redirect to this: * https://danbooru.donmai.u/wiki_pages/touhou Instead of this: * https://danbooru.donmai.u/wiki_pages/touhou.html This also fixes redirects when searching for users on profile pages, and during pagination on media asset show pages. --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6639253bb..5f2bf4af5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -75,7 +75,11 @@ class ApplicationController < ActionController::Base end def redirect_to_show(items) - redirect_to send("#{controller_path.singularize}_path", items.first, format: request.format.symbol) + if request.format.html? + redirect_to send("#{controller_path.singularize}_path", items.first) + else + redirect_to send("#{controller_path.singularize}_path", items.first, format: request.format.symbol) + end end def is_redirect?(items)