Fix #5140: Unexpected error: PublicSuffix::DomainInvalid for searching some newgrounds urls in /artists
When the artist name couldn't found for a Newgrounds URL, for example for `https://www.newgrounds.com/dump/item`, then the `profile_url` method erroneously returned `https://.newgrounds.com`. This led to an error later on when the artist finder tried to parse the invalid URL. Also fix `strategy_should_work` to test that the profile URL is a valid URL, and not to try to download the file when image_urls is empty.
This commit is contained in:
@@ -402,6 +402,16 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "when finding Newgrounds artists" do
|
||||
should "find the correct artist" do
|
||||
create(:artist, name: "lasterk", url_string: "http://lasterk.newgrounds.com")
|
||||
create(:artist, name: "merunyaa", url_string: "https://merunyaa.newgrounds.com")
|
||||
|
||||
assert_artist_found("lasterk", "https://www.newgrounds.com/art/view/lasterk/booette")
|
||||
assert_artist_not_found("https://www.newgrounds.com/dump/item/a1f417d20f5eaef31e26ac3c4956b3d4")
|
||||
end
|
||||
end
|
||||
|
||||
context "the #normalize_other_names method" do
|
||||
subject { build(:artist) }
|
||||
|
||||
|
||||
@@ -98,6 +98,15 @@ module Sources
|
||||
end
|
||||
end
|
||||
|
||||
context "A www.newgrounds.com/dump/item URL" do
|
||||
strategy_should_work(
|
||||
"https://www.newgrounds.com/dump/item/a1f417d20f5eaef31e26ac3c4956b3d4",
|
||||
image_urls: [],
|
||||
artist_name: nil,
|
||||
profile_url: nil,
|
||||
)
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user