From a68ff3c34712a17d0264726f3074152175d98fc3 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 5 Jun 2017 17:08:05 -0500 Subject: [PATCH] artstation: accept www.artstation.com/artwork/foo-bar-baz style urls. --- app/logical/sources/strategies/art_station.rb | 5 ++++- test/unit/sources/art_station_test.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/logical/sources/strategies/art_station.rb b/app/logical/sources/strategies/art_station.rb index a141cc98b..be73b183e 100644 --- a/app/logical/sources/strategies/art_station.rb +++ b/app/logical/sources/strategies/art_station.rb @@ -6,8 +6,11 @@ module Sources::Strategies self.project_id(url).present? end + # https://www.artstation.com/artwork/04XA4" + # https://dantewontdie.artstation.com/projects/YZK5q" + # https://www.artstation.com/artwork/cody-from-sf" def self.project_id(url) - if url =~ %r!\Ahttps?://\w+\.artstation\.com/(?:artwork|projects)/(?[a-z0-9]+)\z!i + if url =~ %r!\Ahttps?://\w+\.artstation\.com/(?:artwork|projects)/(?[a-z0-9-]+)\z!i $~[:project_id] else nil diff --git a/test/unit/sources/art_station_test.rb b/test/unit/sources/art_station_test.rb index ad149f402..a3a329e4e 100644 --- a/test/unit/sources/art_station_test.rb +++ b/test/unit/sources/art_station_test.rb @@ -58,5 +58,17 @@ module Sources assert_equal("From Gantz.", @site.artist_commentary_desc) end end + + context "The source site for a www.artstation.com/artwork/$slug page" do + setup do + @site = Sources::Site.new("https://www.artstation.com/artwork/cody-from-sf") + @site.get + end + + should "get the image url" do + url = "https://cdna.artstation.com/p/assets/images/images/000/144/922/original/cassio-yoshiyaki-cody2backup2-yoshiyaki.jpg?1406314198" + assert_equal(url, @site.image_url) + end + end end end