mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-12-24 02:35:03 +01:00
title parse improvement
This commit is contained in:
parent
f1d5c0f079
commit
1f4fbe9d98
@ -48,6 +48,6 @@ defmodule Pleroma.Web.RichMedia.Parsers.MetaTagsParser do
|
||||
defp maybe_put_title(meta, _), do: meta
|
||||
|
||||
defp get_page_title(html) do
|
||||
Floki.find(html, "title") |> List.first() |> Floki.text()
|
||||
Floki.find(html, "html head title") |> List.first() |> Floki.text()
|
||||
end
|
||||
end
|
||||
|
228
test/fixtures/nypd-facial-recognition-children-teenagers4.html
vendored
Normal file
228
test/fixtures/nypd-facial-recognition-children-teenagers4.html
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -85,4 +85,19 @@ defmodule Pleroma.Web.RichMedia.Parsers.TwitterCardTest do
|
||||
image: image_path
|
||||
}}
|
||||
end
|
||||
|
||||
test "takes first founded title in html head if there is html markup error" do
|
||||
html = File.read!("test/fixtures/nypd-facial-recognition-children-teenagers4.html")
|
||||
|
||||
assert TwitterCard.parse(html, %{}) ==
|
||||
{:ok,
|
||||
%{
|
||||
site: nil,
|
||||
title:
|
||||
"She Was Arrested at 14. Then Her Photo Went to a Facial Recognition Database. - The New York Times",
|
||||
"app:id:googleplay": "com.nytimes.android",
|
||||
"app:name:googleplay": "NYTimes",
|
||||
"app:url:googleplay": "nytimes://reader/id/100000006583622"
|
||||
}}
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user