pixiv: fix failure when normalizing pixiv stacc artist urls (#3856).

This commit is contained in:
evazion
2018-08-30 19:24:44 -05:00
parent 4c85cf4a32
commit c689a161f6
2 changed files with 8 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ module Sources
IMG = %r!(?:\A(?:https?://)?img[0-9]*\.pixiv\.net)!
PXIMG = %r!(?:\A(?:https?://)?i\.pximg\.net)!
TOUCH = %r!(?:\A(?:https?://)?touch\.pixiv\.net)!
STACC_PAGE = %r!\A#{WEB}/stacc/#{MONIKER}/?\z!i
NOVEL_PAGE = %r!(?:\Ahttps?://www\.pixiv\.net/novel/show\.php\?id=(\d+))!
FANBOX_IMAGE = %r!(?:\Ahttps?://fanbox\.pixiv\.net/images/post/(\d+))!
FANBOX_PAGE = %r!(?:\Ahttps?://www\.pixiv\.net/fanbox/creator/\d+/post/(\d+))!
@@ -117,7 +118,7 @@ module Sources
end
def normalized_for_artist_finder?
url =~ PROFILE
url =~ PROFILE || url =~ STACC_PAGE
end
def normalizable_for_artist_finder?

View File

@@ -129,6 +129,12 @@ class ArtistUrlTest < ActiveSupport::TestCase
assert_equal("http://www.pixiv.net/member.php?id=339253/", url.normalized_url)
end
should "normalize pixiv stacc urls" do
url = FactoryBot.create(:artist_url, :url => "https://www.pixiv.net/stacc/evazion")
assert_equal("https://www.pixiv.net/stacc/evazion", url.url)
assert_equal("http://www.pixiv.net/stacc/evazion/", url.normalized_url)
end
should "normalize twitter urls" do
url = FactoryBot.create(:artist_url, :url => "https://twitter.com/aoimanabu/status/892370963630743552")
assert_equal("https://twitter.com/aoimanabu/status/892370963630743552", url.url)