[#1794] Fixed search query splitting regex to deal with Unicode. Adjusted a test.
authorIvan Tashkinov <ivantashkinov@gmail.com>
Sat, 30 May 2020 07:29:08 +0000 (10:29 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Sat, 30 May 2020 07:29:08 +0000 (10:29 +0300)
lib/pleroma/web/mastodon_api/controllers/search_controller.ex
test/web/mastodon_api/controllers/search_controller_test.exs

index 23fe378a64714f6304a94f69d6d6bc3cfca09350..8840fc19ce790d7c11695035705f11c037687465 100644 (file)
@@ -124,7 +124,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
   defp prepare_tags(query, add_joined_tag \\ true) do
     tags =
       query
-      |> String.split(~r/[^#\w]+/, trim: true)
+      |> String.split(~r/[^#\w]+/u, trim: true)
       |> Enum.uniq_by(&String.downcase/1)
 
     explicit_tags = Enum.filter(tags, fn tag -> String.starts_with?(tag, "#") end)
index 49829037796930863e1112aa5308f9542cf728ed..84d46895edcb7b436cd57ed4022c0e597975211c 100644 (file)
@@ -71,6 +71,10 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
         get(conn, "/api/v2/search?q=天子")
         |> json_response_and_validate_schema(200)
 
+      assert results["hashtags"] == [
+               %{"name" => "天子", "url" => "#{Web.base_url()}/tag/天子"}
+             ]
+
       [status] = results["statuses"]
       assert status["id"] == to_string(activity.id)
     end