Kaynağa Gözat

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

1570-levenshtein-distance-user-search
Ivan Tashkinov 4 yıl önce
ebeveyn
işleme
24f40b8a26
2 değiştirilmiş dosya ile 5 ekleme ve 1 silme
  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 Dosyayı Görüntüle

@@ -124,7 +124,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
defp prepare_tags(query, add_joined_tag \\ true) do defp prepare_tags(query, add_joined_tag \\ true) do
tags = tags =
query query
|> String.split(~r/[^#\w]+/, trim: true)
|> String.split(~r/[^#\w]+/u, trim: true)
|> Enum.uniq_by(&String.downcase/1) |> Enum.uniq_by(&String.downcase/1)


explicit_tags = Enum.filter(tags, fn tag -> String.starts_with?(tag, "#") end) explicit_tags = Enum.filter(tags, fn tag -> String.starts_with?(tag, "#") end)


+ 4
- 0
test/web/mastodon_api/controllers/search_controller_test.exs Dosyayı Görüntüle

@@ -71,6 +71,10 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
get(conn, "/api/v2/search?q=天子") get(conn, "/api/v2/search?q=天子")
|> json_response_and_validate_schema(200) |> json_response_and_validate_schema(200)


assert results["hashtags"] == [
%{"name" => "天子", "url" => "#{Web.base_url()}/tag/天子"}
]

[status] = results["statuses"] [status] = results["statuses"]
assert status["id"] == to_string(activity.id) assert status["id"] == to_string(activity.id)
end end


Yükleniyor…
İptal
Kaydet