Kaynağa Gözat

title parse improvement

revert/attachment-cleanup
Alexander Strizhakov 4 yıl önce
ebeveyn
işleme
1f4fbe9d98
Veri tabanında bu imza için bilinen anahtar bulunamadı GPG Anahtar Kimliği: 22896A53AEF1381
3 değiştirilmiş dosya ile 244 ekleme ve 1 silme
  1. +1
    -1
      lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex
  2. +228
    -0
      test/fixtures/nypd-facial-recognition-children-teenagers4.html
  3. +15
    -0
      test/web/rich_media/parsers/twitter_card_test.exs

+ 1
- 1
lib/pleroma/web/rich_media/parsers/meta_tags_parser.ex Dosyayı Görüntüle

@@ -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
- 0
test/fixtures/nypd-facial-recognition-children-teenagers4.html
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 15
- 0
test/web/rich_media/parsers/twitter_card_test.exs Dosyayı Görüntüle

@@ -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

Yükleniyor…
İptal
Kaydet