normalize search string in filter compilation

This commit is contained in:
byte[] 2019-11-14 22:15:25 -05:00
parent ae489ef6ea
commit 4915fb5044
2 changed files with 6 additions and 1 deletions

View file

@ -1,5 +1,6 @@
defmodule PhilomenaWeb.Plugs.ImageFilter do
import Plug.Conn
import Search.String
alias Philomena.Images.Query
alias Pow.Plug
@ -13,7 +14,7 @@ defmodule PhilomenaWeb.Plugs.ImageFilter do
filter = conn.assigns[:current_filter]
tag_exclusion = %{terms: %{tag_ids: filter.hidden_tag_ids}}
{:ok, query_exclusion} = Query.compile(user, filter.hidden_complex_str)
{:ok, query_exclusion} = Query.compile(user, normalize(filter.hidden_complex_str))
query = %{
bool: %{

View file

@ -1,4 +1,8 @@
defmodule Search.String do
def normalize(nil) do
""
end
def normalize(str) do
str
|> String.replace("\r", "")