diff options
author | kaniini <ariadne@dereferenced.org> | 2019-08-03 18:13:21 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-08-03 18:13:21 +0000 |
commit | 99ce6d6044606f8a91cb101c7f08a493a6644ee8 (patch) | |
tree | dd0384e3ba1d7f06d5476ac265bf482a60ef1a5a | |
parent | 7319b41e340ac17ed7f31f89cd0edc959de270ce (diff) | |
parent | 040347b24820e2773c45a38d4cb6a184d6b14366 (diff) | |
download | pleroma-99ce6d6044606f8a91cb101c7f08a493a6644ee8.tar.gz pleroma-99ce6d6044606f8a91cb101c7f08a493a6644ee8.zip |
Merge branch 'fix/search-space-error' into 'develop'
Remove spaces from the domain search
Closes #1154
See merge request pleroma/pleroma!1521
-rw-r--r-- | lib/pleroma/user/search.ex | 2 | ||||
-rw-r--r-- | test/web/mastodon_api/search_controller_test.exs | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/pleroma/user/search.ex b/lib/pleroma/user/search.ex index 46620b89a..6fb2c2352 100644 --- a/lib/pleroma/user/search.ex +++ b/lib/pleroma/user/search.ex @@ -44,7 +44,7 @@ defmodule Pleroma.User.Search 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 diff --git a/test/web/mastodon_api/search_controller_test.exs b/test/web/mastodon_api/search_controller_test.exs index 043b96c14..49c79ff0a 100644 --- a/test/web/mastodon_api/search_controller_test.exs +++ b/test/web/mastodon_api/search_controller_test.exs @@ -95,6 +95,18 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest 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 |