From 3dc914488c2e52968e1a5f9086c6219d24a20d18 Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Fri, 9 Jul 2021 09:30:23 +0300 Subject: [PATCH] Do not redirect to 404 page with empty string in the search --- CHANGELOG.md | 1 + .../lib/block_scout_web/controllers/chain_controller.ex | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96cb86568a..78f634f0c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes ### Chore +- [#4355](https://github.com/blockscout/blockscout/pull/4355) - Do not redirect to 404 page with empty string in the search field ## 3.7.1-beta diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex index 338c9096e0..ea17c13bcc 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex @@ -78,6 +78,10 @@ defmodule BlockScoutWeb.ChainController do %{earliest: x_days_back, latest: latest} end + def search(conn, %{"q" => ""}) do + show(conn, []) + end + def search(conn, %{"q" => query}) do query |> String.trim()