Merge branch '1794-hashtags-construction-from-uri-fix' into 'develop'
[#1794] Fixes URI query handling for hashtags extraction in search Closes #1794 See merge request pleroma/pleroma!2645
This commit is contained in:
commit
11aa02bb10
|
@ -152,6 +152,7 @@ defp prepare_tags(query, add_joined_tag \\ true) do
|
||||||
defp preprocess_uri_query(query) do
|
defp preprocess_uri_query(query) do
|
||||||
if query =~ ~r/https?:\/\// do
|
if query =~ ~r/https?:\/\// do
|
||||||
query
|
query
|
||||||
|
|> String.trim_trailing("/")
|
||||||
|> URI.parse()
|
|> URI.parse()
|
||||||
|> Map.get(:path)
|
|> Map.get(:path)
|
||||||
|> String.split("/")
|
|> String.split("/")
|
||||||
|
|
|
@ -120,6 +120,35 @@ test "constructs hashtags from search query", %{conn: conn} do
|
||||||
assert results["hashtags"] == [
|
assert results["hashtags"] == [
|
||||||
%{"name" => "shpuld", "url" => "#{Web.base_url()}/tag/shpuld"}
|
%{"name" => "shpuld", "url" => "#{Web.base_url()}/tag/shpuld"}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
results =
|
||||||
|
conn
|
||||||
|
|> get(
|
||||||
|
"/api/v2/search?#{
|
||||||
|
URI.encode_query(%{
|
||||||
|
q:
|
||||||
|
"https://www.washingtonpost.com/sports/2020/06/10/" <>
|
||||||
|
"nascar-ban-display-confederate-flag-all-events-properties/"
|
||||||
|
})
|
||||||
|
}"
|
||||||
|
)
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert results["hashtags"] == [
|
||||||
|
%{"name" => "nascar", "url" => "#{Web.base_url()}/tag/nascar"},
|
||||||
|
%{"name" => "ban", "url" => "#{Web.base_url()}/tag/ban"},
|
||||||
|
%{"name" => "display", "url" => "#{Web.base_url()}/tag/display"},
|
||||||
|
%{"name" => "confederate", "url" => "#{Web.base_url()}/tag/confederate"},
|
||||||
|
%{"name" => "flag", "url" => "#{Web.base_url()}/tag/flag"},
|
||||||
|
%{"name" => "all", "url" => "#{Web.base_url()}/tag/all"},
|
||||||
|
%{"name" => "events", "url" => "#{Web.base_url()}/tag/events"},
|
||||||
|
%{"name" => "properties", "url" => "#{Web.base_url()}/tag/properties"},
|
||||||
|
%{
|
||||||
|
"name" => "NascarBanDisplayConfederateFlagAllEventsProperties",
|
||||||
|
"url" =>
|
||||||
|
"#{Web.base_url()}/tag/NascarBanDisplayConfederateFlagAllEventsProperties"
|
||||||
|
}
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "excludes a blocked users from search results", %{conn: conn} do
|
test "excludes a blocked users from search results", %{conn: conn} do
|
||||||
|
|
Loading…
Reference in a new issue