From b3f92dd2c7c9d83b06e438eb2f12d7f71f7e9b99 Mon Sep 17 00:00:00 2001 From: nonamethanks Date: Sun, 3 Jan 2021 20:12:40 +0100 Subject: [PATCH] Fix gelbooru source normalization --- app/logical/sources/strategies/null.rb | 2 +- test/unit/sources/null_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/logical/sources/strategies/null.rb b/app/logical/sources/strategies/null.rb index 4dd02ebe6..86ff2e530 100644 --- a/app/logical/sources/strategies/null.rb +++ b/app/logical/sources/strategies/null.rb @@ -57,7 +57,7 @@ module Sources # http://simg.gelbooru.com//images/2003/edd1d2b3881cf70c3acf540780507531.png # https://simg3.gelbooru.com//samples/0b/3a/sample_0b3ae5e225072b8e391c827cb470d29c.jpg when %r{\Ahttps?://(?:\w+\.)?gelbooru\.com//?(?:images|samples)/(?:\d+|\h\h/\h\h)/(?:sample_)?(?\h{32})\.}i - "https://gelbooru.com/index.php?page=post&s=list&md5=#{$~[:md5]}" + "https://gelbooru.com/index.php?page=post&s=list&tags=md5:#{$~[:md5]}" when %r{\Ahttps?://(?:slot\d*\.)?im(?:g|ages)\d*\.wikia\.(?:nocookie\.net|com)/(?:_{2}cb\d{14}/)?([^/]+)(?:/[a-z]{2})?/images/(?:(?:thumb|archive)?/)?[a-f0-9]/[a-f0-9]{2}/(?:\d{14}(?:!|%21))?([^/]+)}i subdomain = $1 diff --git a/test/unit/sources/null_test.rb b/test/unit/sources/null_test.rb index b1ef6e3a1..c2ff5a07e 100644 --- a/test/unit/sources/null_test.rb +++ b/test/unit/sources/null_test.rb @@ -85,9 +85,9 @@ module Sources source2 = "http://simg.gelbooru.com//images/2003/edd1d2b3881cf70c3acf540780507531.png" source3 = "https://simg3.gelbooru.com//samples/0b/3a/sample_0b3ae5e225072b8e391c827cb470d29c.jpg" - assert_equal("https://gelbooru.com/index.php?page=post&s=list&md5=ee5c9a69db9602c95debdb9b98fb3e3e", Sources::Strategies.normalize_source(source1)) - assert_equal("https://gelbooru.com/index.php?page=post&s=list&md5=edd1d2b3881cf70c3acf540780507531", Sources::Strategies.normalize_source(source2)) - assert_equal("https://gelbooru.com/index.php?page=post&s=list&md5=0b3ae5e225072b8e391c827cb470d29c", Sources::Strategies.normalize_source(source3)) + assert_equal("https://gelbooru.com/index.php?page=post&s=list&tags=md5:ee5c9a69db9602c95debdb9b98fb3e3e", Sources::Strategies.normalize_source(source1)) + assert_equal("https://gelbooru.com/index.php?page=post&s=list&tags=md5:edd1d2b3881cf70c3acf540780507531", Sources::Strategies.normalize_source(source2)) + assert_equal("https://gelbooru.com/index.php?page=post&s=list&tags=md5:0b3ae5e225072b8e391c827cb470d29c", Sources::Strategies.normalize_source(source3)) end should "normalize wikia links" do