diff --git a/app/logical/sources/site.rb b/app/logical/sources/site.rb index 6ff87d8c6..f86944a68 100644 --- a/app/logical/sources/site.rb +++ b/app/logical/sources/site.rb @@ -14,12 +14,12 @@ module Sources [Strategies::PixivWhitecube, Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::ArtStation, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr, Strategies::Pawoo] end - def initialize(url, options = {}) + def initialize(url, referer_url: nil) @url = url Site.strategies.each do |strategy| - if strategy.url_match?(url) - @strategy = strategy.new(url, options[:referer_url]) + if strategy.url_match?(url) || strategy.url_match?(referer_url) + @strategy = strategy.new(url, referer_url) break end end diff --git a/test/unit/sources/art_station_test.rb b/test/unit/sources/art_station_test.rb index 9361f10cd..2fb3ef76f 100644 --- a/test/unit/sources/art_station_test.rb +++ b/test/unit/sources/art_station_test.rb @@ -71,6 +71,19 @@ module Sources end end + context "The source site for a http://cdna.artstation.com/p/assets/... url" do + setup do + @url = "https://cdna.artstation.com/p/assets/images/images/006/029/978/large/amama-l-z.jpg" + @ref = "https://www.artstation.com/artwork/4BWW2" + @site = Sources::Site.new(@url, referer_url: @ref) + @site.get + end + + should "fetch the source data" do + assert_equal("amama", @site.artist_name) + end + end + context "The source site for an ArtStation gallery" do setup do @site = Sources::Site.new("https://www.artstation.com/artwork/BDxrA")