forked from AkkomaGang/akkoma
[#1794] Fixed search query splitting regex to deal with Unicode. Adjusted a test.
This commit is contained in:
parent
78c80a261a
commit
24f40b8a26
2 changed files with 5 additions and 1 deletions
|
@ -124,7 +124,7 @@ defp resource_search(:v1, "hashtags", query, _options) 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)
|
||||||
|
|
|
@ -71,6 +71,10 @@ test "search", %{conn: conn} 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
|
||||||
|
|
Loading…
Reference in a new issue