deviantart: fix artist finder for artist names with underscores.

Fix the artist finder for urls like this:

  https://orig00.deviantart.net/4274/f/2010/230/8/a/pkmn_king_and_queen_by_mikoto_chan.jpg

that don't contain a deviantart id but do contain the artist name.
This commit is contained in:
evazion
2018-09-07 12:23:48 -05:00
parent 610391205f
commit a67edb8783
2 changed files with 11 additions and 1 deletions

View File

@@ -182,7 +182,7 @@ module Sources
def self.artist_name_from_url(url)
if url =~ ASSET || url =~ PATH_ART || url =~ PATH_PROFILE
$~[:artist]
$~[:artist].try(:dasherize)
elsif url !~ RESERVED_SUBDOMAINS && (url =~ SUBDOMAIN_ART || url =~ SUBDOMAIN_PROFILE)
$~[:artist]
else

View File

@@ -82,6 +82,16 @@ module Sources
end
end
context "A source for a *.deviantart.net/*/:title_by_:artist.jpg url artist name containing underscores" do
should "find the correct artist" do
@site = Sources::Strategies.find("https://orig00.deviantart.net/4274/f/2010/230/8/a/pkmn_king_and_queen_by_mikoto_chan.jpg")
@artist = FactoryBot.create(:artist, name: "mikoto-chan", url_string: "https://www.deviantart.com/mikoto-chan")
assert_equal("mikoto-chan", @site.artist_name)
assert_equal([@artist], @site.artists)
end
end
context "The source for a *.deviantart.net/*/:title_by_:artist.jpg url" do
setup do
@url = "http://fc08.deviantart.net/files/f/2007/120/c/9/cool_like_me_by_47ness.jpg"