artstation: accept www.artstation.com/artwork/foo-bar-baz style urls.

This commit is contained in:
evazion
2017-06-05 17:08:05 -05:00
parent bb0be36f05
commit a68ff3c347
2 changed files with 16 additions and 1 deletions

View File

@@ -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)/(?<project_id>[a-z0-9]+)\z!i
if url =~ %r!\Ahttps?://\w+\.artstation\.com/(?:artwork|projects)/(?<project_id>[a-z0-9-]+)\z!i
$~[:project_id]
else
nil

View File

@@ -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