Skip to content
Snippets Groups Projects
Commit 99ce6d60 authored by kaniini's avatar kaniini
Browse files

Merge branch 'fix/search-space-error' into 'develop'

Remove spaces from the domain search

Closes #1154

See merge request pleroma/pleroma!1521
parents 7319b41e 040347b2
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ defp format_query(query_string) do
query_string = String.trim_leading(query_string, "@")
with [name, domain] <- String.split(query_string, "@"),
formatted_domain <- String.replace(domain, ~r/[!-\-|@|[-`|{-~|\/|:]+/, "") do
formatted_domain <- String.replace(domain, ~r/[!-\-|@|[-`|{-~|\/|:|\s]+/, "") do
name <> "@" <> to_string(:idna.encode(formatted_domain))
else
_ -> query_string
......
......@@ -95,6 +95,18 @@ test "account search", %{conn: conn} do
assert user_three.nickname in result_ids
end
test "returns account if query contains a space", %{conn: conn} do
user = insert(:user, %{nickname: "shp@shitposter.club"})
results =
conn
|> assign(:user, user)
|> get("/api/v1/accounts/search", %{"q" => "shp@shitposter.club xxx "})
|> json_response(200)
assert length(results) == 1
end
end
describe ".search" do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment