artstation: normalize https://artstation.com/artist/username/albums/all/ urls.
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
class Source::URL::ArtStation < Source::URL
|
class Source::URL::ArtStation < Source::URL
|
||||||
RESERVED_SUBDOMAINS = %w[www cdn cdna cdnb]
|
RESERVED_SUBDOMAINS = %w[www cdn cdna cdnb]
|
||||||
IMAGE_SUBDOMAINS = %w[cdn cdna cdnb]
|
|
||||||
|
|
||||||
attr_reader :username, :work_id
|
attr_reader :username, :work_id
|
||||||
|
|
||||||
@@ -35,17 +34,24 @@ class Source::URL::ArtStation < Source::URL
|
|||||||
@work_id = work_id
|
@work_id = work_id
|
||||||
@username = subdomain unless subdomain.in?(RESERVED_SUBDOMAINS)
|
@username = subdomain unless subdomain.in?(RESERVED_SUBDOMAINS)
|
||||||
|
|
||||||
|
# https://artstation.com/artist/sa-dui
|
||||||
# https://www.artstation.com/artist/sa-dui
|
# https://www.artstation.com/artist/sa-dui
|
||||||
in "www.artstation.com", "artist", username
|
# https://www.artstation.com/artist/chicle/albums/all/
|
||||||
|
in _, "artist", username, *rest
|
||||||
@username = username
|
@username = username
|
||||||
|
|
||||||
|
# http://artstation.com/sha_sha
|
||||||
# https://www.artstation.com/sa-dui
|
# https://www.artstation.com/sa-dui
|
||||||
# https://www.artstation.com/felipecartin/profile
|
# https://www.artstation.com/felipecartin/profile
|
||||||
in "www.artstation.com", username, *rest
|
# https://www.artstation.com/chicle/albums/all
|
||||||
|
# https://www.artstation.com/h-battousai/albums/1480261
|
||||||
|
# http://www.artstation.com/envie_dai/prints
|
||||||
|
in ("www.artstation.com" | "artstation.com"), username, *rest
|
||||||
@username = username
|
@username = username
|
||||||
|
|
||||||
# https://sa-dui.artstation.com
|
# https://sa-dui.artstation.com
|
||||||
# https://hosi_na.artstation.com
|
# https://hosi_na.artstation.com
|
||||||
|
# https://heyjay.artstation.com/store/art_posters
|
||||||
in *rest unless subdomain.in?(RESERVED_SUBDOMAINS)
|
in *rest unless subdomain.in?(RESERVED_SUBDOMAINS)
|
||||||
@username = subdomain
|
@username = subdomain
|
||||||
|
|
||||||
@@ -54,7 +60,7 @@ class Source::URL::ArtStation < Source::URL
|
|||||||
end
|
end
|
||||||
|
|
||||||
def image_url?
|
def image_url?
|
||||||
@file.present?
|
subdomain.starts_with?("cdn")
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_image_url(size = "original")
|
def full_image_url(size = "original")
|
||||||
|
|||||||
@@ -64,13 +64,17 @@ class ArtistURLTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "normalize ArtStation urls" do
|
should "normalize ArtStation urls" do
|
||||||
url = create(:artist_url, url: "https://www.artstation.com/koyorin")
|
url = create(:artist_url, url: "https://artstation.com/koyorin")
|
||||||
assert_equal("https://www.artstation.com/koyorin", url.url)
|
assert_equal("https://www.artstation.com/koyorin", url.url)
|
||||||
assert_equal("http://www.artstation.com/koyorin/", url.normalized_url)
|
assert_equal("http://www.artstation.com/koyorin/", url.normalized_url)
|
||||||
|
|
||||||
url = create(:artist_url, url: "https://koyorin.artstation.com")
|
url = create(:artist_url, url: "https://koyorin.artstation.com")
|
||||||
assert_equal("https://www.artstation.com/koyorin", url.url)
|
assert_equal("https://www.artstation.com/koyorin", url.url)
|
||||||
assert_equal("http://www.artstation.com/koyorin/", url.normalized_url)
|
assert_equal("http://www.artstation.com/koyorin/", url.normalized_url)
|
||||||
|
|
||||||
|
url = create(:artist_url, url: "https://www.artstation.com/artist/koyorin/albums/all/")
|
||||||
|
assert_equal("https://www.artstation.com/koyorin", url.url)
|
||||||
|
assert_equal("http://www.artstation.com/koyorin/", url.normalized_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "normalize fc2 urls" do
|
should "normalize fc2 urls" do
|
||||||
|
|||||||
Reference in New Issue
Block a user