From d124ff812831371cee5d04d107a4901bc38476f3 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 23 Aug 2017 17:50:33 -0700 Subject: [PATCH] fix case when fetching pixiv sources when illust_id param comes before mode --- app/logical/sources/strategies/pixiv.rb | 2 +- test/unit/sources/pixiv_test.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb index 2211ff18e..5632a196a 100644 --- a/app/logical/sources/strategies/pixiv.rb +++ b/app/logical/sources/strategies/pixiv.rb @@ -310,7 +310,7 @@ module Sources end def work_page? - return true if url =~ %r!(?:#{WEB}|#{TOUCH})/member_illust\.php\?mode=(?:medium|big|manga|manga_big)&illust_id=\d+!i + return true if url =~ %r!(?:#{WEB}|#{TOUCH})/member_illust\.php! && url =~ %r!mode=(?:medium|big|manga|manga_big)! && url =~ %r!illust_id=\d+! return true if url =~ %r!(?:#{WEB}|#{TOUCH})/i/\d+$!i return false end diff --git a/test/unit/sources/pixiv_test.rb b/test/unit/sources/pixiv_test.rb index fd5523826..70e9629a2 100644 --- a/test/unit/sources/pixiv_test.rb +++ b/test/unit/sources/pixiv_test.rb @@ -113,6 +113,20 @@ module Sources end end + context "fetching source for an illustration with swapped illust_id/mode parameters" do + setup do + get_source("https://www.pixiv.net/member_illust.php?illust_id=64476642&mode=medium") + end + + should "get the page count" do + assert_equal(1, @site.image_urls.size) + end + + should "get the full size image url" do + assert_equal("https://i.pximg.net/img-original/img/2017/08/18/00/09/21/64476642_p0.jpg", @site.image_url) + end + end + context "fetching the commentary" do should "work when the description is blank" do get_source("https://www.pixiv.net/member_illust.php?mode=medium&illust_id=46337015")