From f60fce614bb170b5d5c6d2b76391dd4efbb279d6 Mon Sep 17 00:00:00 2001 From: nonamethanks Date: Sun, 8 Aug 2021 15:46:30 +0200 Subject: [PATCH] Fix lofter strategy due to changes in their image urls --- app/logical/sources/strategies/lofter.rb | 3 +-- test/unit/sources/lofter_test.rb | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/logical/sources/strategies/lofter.rb b/app/logical/sources/strategies/lofter.rb index 24e3d4530..cd8839291 100644 --- a/app/logical/sources/strategies/lofter.rb +++ b/app/logical/sources/strategies/lofter.rb @@ -23,7 +23,6 @@ module Sources PROFILE_URL = %r{\Ahttps?://(?[\w-]+).lofter.com}i PAGE_URL = %r{#{PROFILE_URL}/post/(?[\w-]+)}i IMAGE_HOST = %r{\Ahttps?://imglf\d\.(?:nosdn\d?\.12\d|lf127)\.net}i - IMAGE_URL = %r{#{IMAGE_HOST}/img/\w+\.\w+}i def domains ["lofter.com", "lf127.net"] @@ -39,7 +38,7 @@ module Sources end def image_url - if url =~ IMAGE_URL + if url =~ IMAGE_HOST get_full_version(url) else image_urls.first diff --git a/test/unit/sources/lofter_test.rb b/test/unit/sources/lofter_test.rb index cf30be2f0..eb71a7b49 100644 --- a/test/unit/sources/lofter_test.rb +++ b/test/unit/sources/lofter_test.rb @@ -47,12 +47,9 @@ module Sources context "A different CSS schema" do should "still find all the data" do source1 = Sources::Strategies.find("https://yuli031458.lofter.com/post/3163d871_1cbdc5f6d") - source2 = Sources::Strategies.find("https://ssucrose.lofter.com/post/1d30f3e4_1cc58e9f0") assert_equal(["https://imglf5.lf127.net/img/Mm55d3lNK2tJUWpNTjVLN0MvaTRDc1UvQUFLMGszOHRvSjV6S3VSa1lwa3BDWUtVOWpBTHBnPT0.jpg"], source1.image_urls) assert_not_empty(source1.tags) - - assert_equal(["https://imglf5.lf127.net/img/d052Q09DWkVNMVJwZm9rNURwNHdPcjlzRFlQc1BmTXArSG9TdXdJZnlCbUpEYnZJTHUwTGRRPT0.jpg"], source2.image_urls) end end