mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 03:17:51 +00:00
Remove spaces from the domain search
This commit is contained in:
parent
7319b41e34
commit
040347b248
2 changed files with 13 additions and 1 deletions
|
@ -44,7 +44,7 @@ defmodule Pleroma.User.Search do
|
||||||
query_string = String.trim_leading(query_string, "@")
|
query_string = String.trim_leading(query_string, "@")
|
||||||
|
|
||||||
with [name, domain] <- String.split(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))
|
name <> "@" <> to_string(:idna.encode(formatted_domain))
|
||||||
else
|
else
|
||||||
_ -> query_string
|
_ -> query_string
|
||||||
|
|
|
@ -95,6 +95,18 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
||||||
|
|
||||||
assert user_three.nickname in result_ids
|
assert user_three.nickname in result_ids
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe ".search" do
|
describe ".search" do
|
||||||
|
|
Loading…
Reference in a new issue