mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
normalize search string in filter compilation
This commit is contained in:
parent
ae489ef6ea
commit
4915fb5044
2 changed files with 6 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
defmodule PhilomenaWeb.Plugs.ImageFilter do
|
defmodule PhilomenaWeb.Plugs.ImageFilter do
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
|
import Search.String
|
||||||
|
|
||||||
alias Philomena.Images.Query
|
alias Philomena.Images.Query
|
||||||
alias Pow.Plug
|
alias Pow.Plug
|
||||||
|
@ -13,7 +14,7 @@ defmodule PhilomenaWeb.Plugs.ImageFilter do
|
||||||
filter = conn.assigns[:current_filter]
|
filter = conn.assigns[:current_filter]
|
||||||
|
|
||||||
tag_exclusion = %{terms: %{tag_ids: filter.hidden_tag_ids}}
|
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 = %{
|
query = %{
|
||||||
bool: %{
|
bool: %{
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
defmodule Search.String do
|
defmodule Search.String do
|
||||||
|
def normalize(nil) do
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
def normalize(str) do
|
def normalize(str) do
|
||||||
str
|
str
|
||||||
|> String.replace("\r", "")
|
|> String.replace("\r", "")
|
||||||
|
|
Loading…
Reference in a new issue