Browse Source

[#1794] Fixed search query splitting regex to deal with Unicode. Adjusted a test.

1570-levenshtein-distance-user-search
Ivan Tashkinov 4 years ago
parent
commit
24f40b8a26
2 changed files with 5 additions and 1 deletions
  1. +1
    -1
      lib/pleroma/web/mastodon_api/controllers/search_controller.ex
  2. +4
    -0
      test/web/mastodon_api/controllers/search_controller_test.exs

+ 1
- 1
lib/pleroma/web/mastodon_api/controllers/search_controller.ex View 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)


+ 4
- 0
test/web/mastodon_api/controllers/search_controller_test.exs View 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


Loading…
Cancel
Save