From 610391205fcf91b2fb87bf15331eefb9cc440977 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 7 Sep 2018 11:36:48 -0500 Subject: [PATCH] deviantart: fix artist finder for profile urls missing the 'www'. Fix the artist finder to work when the profile url in the artist entry is missing the 'www'. Example: https://deviantart.com/noizave https://www.deviantart.com/noizave --- app/logical/sources/strategies/deviant_art.rb | 10 ++++++++-- test/unit/sources/deviantart_test.rb | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index f593950b9..2f1d7952c 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -24,6 +24,12 @@ # * https://noizave.deviantart.com/art/test-post-please-ignore-685436408 # * https://www.deviantart.com/deviation/685436408 # * https://fav.me/dbc3a48 +# +# Profile URLs: +# +# * https://noizave.deviantart.com +# * https://www.deviantart.com/noizave +# * https://deviantart.com/noizave module Sources module Strategies @@ -40,7 +46,7 @@ module Sources PATH_ART = %r{\Ahttps?://www\.deviantart\.com/#{ARTIST}/art/#{TITLE}-#{DEVIATION_ID}\z}i SUBDOMAIN_ART = %r{\Ahttps?://#{ARTIST}\.deviantart\.com/art/#{TITLE}-#{DEVIATION_ID}\z}i - PATH_PROFILE = %r{\Ahttps?://www\.deviantart\.com/#{ARTIST}/?\z}i + PATH_PROFILE = %r{\Ahttps?://(www\.)?deviantart\.com/#{ARTIST}/?\z}i SUBDOMAIN_PROFILE = %r{\Ahttps?://#{ARTIST}\.deviantart\.com/?\z}i def self.match?(*urls) @@ -111,7 +117,7 @@ module Sources end def normalized_for_artist_finder? - url =~ PATH_PROFILE + url == normalize_for_artist_finder end def normalizable_for_artist_finder? diff --git a/test/unit/sources/deviantart_test.rb b/test/unit/sources/deviantart_test.rb index 4bf3960c1..88cc4bd27 100644 --- a/test/unit/sources/deviantart_test.rb +++ b/test/unit/sources/deviantart_test.rb @@ -229,5 +229,14 @@ module Sources assert_match(%r!"Print available at Inprnt":\[http://www.inprnt.com/gallery/teemutaiga/kisu\]!, @site.dtext_artist_commentary_desc) end end + + context "An artist entry with a profile url that is missing the 'www'" do + should "still find the artist" do + @site = Sources::Strategies.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408") + @artist = FactoryBot.create(:artist, name: "noizave", url_string: "https://deviantart.com/noizave") + + assert_equal([@artist], @site.artists) + end + end end end