diff --git a/app/logical/source/extractor/newgrounds.rb b/app/logical/source/extractor/newgrounds.rb index 7f6effd33..81c41d100 100644 --- a/app/logical/source/extractor/newgrounds.rb +++ b/app/logical/source/extractor/newgrounds.rb @@ -68,11 +68,12 @@ module Source end def artist_commentary_desc - page&.css("#author_comments")&.to_html + return "" if page.nil? + page.dup.css("#author_comments").tap { _1.css("ul.itemlist").remove }.to_html end def dtext_artist_commentary_desc - DText.from_html(artist_commentary_desc) + DText.from_html(artist_commentary_desc).strip end def user_name diff --git a/test/unit/sources/newgrounds_test.rb b/test/unit/sources/newgrounds_test.rb index f7d5121db..6089c7c9b 100644 --- a/test/unit/sources/newgrounds_test.rb +++ b/test/unit/sources/newgrounds_test.rb @@ -98,6 +98,21 @@ module Sources end end + context "A post with links to other illustrations in the commentary" do + should "not include the links in the commentary" do + @source = Source::Extractor.find("https://www.newgrounds.com/art/view/boxofwant/annie-hughes-1") + + assert_equal(<<~EOS.chomp, @source.artist_commentary_desc) +

Commission of Annie Hughes, the mom from The Iron Giant, for @ManStawberry.


+
+ EOS + + assert_equal(<<~EOS.chomp, @source.dtext_artist_commentary_desc) + Commission of Annie Hughes, the mom from The Iron Giant, for "@ManStawberry":[https://twitter.com/ManStawberry]. + EOS + end + end + context "generating page urls" do should "work" do assert_equal("https://www.newgrounds.com/art/view/natthelich/fire-emblem-marth-plus-progress-pic", Source::URL.page_url("https://art.ngfiles.com/images/1033000/1033622_natthelich_fire-emblem-marth-plus-progress-pic.png?f1569487181"))