diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 422ed41c9..470e60ecb 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -174,7 +174,7 @@ class PostQueryBuilder relation = relation.where("(posts.source = '' OR posts.source IS NULL)") elsif q[:source] == "http%" relation = relation.where("(lower(posts.source) like ?)", "http%") - elsif q[:source] =~ /^%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/|(?=%$))(.+)$/i + elsif q[:source] =~ /^(?:https?:\/\/)?%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/img\/|%\/|(?=%$))(.+)$/i relation = relation.where("SourcePattern(lower(posts.source)) LIKE lower(?) ESCAPE E'\\\\'", "pixiv/" + $1) has_constraints! else @@ -188,7 +188,7 @@ class PostQueryBuilder relation = relation.where("(posts.source != '' AND posts.source IS NOT NULL)") elsif q[:source_neg] == "http%" relation = relation.where("(lower(posts.source) not like ?)", "http%") - elsif q[:source_neg] =~ /^%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/|(?=%$))(.+)$/i + elsif q[:source_neg] =~ /^(?:https?:\/\/)?%\.?pixiv(?:\.net(?:\/img)?)?(?:%\/img\/|%\/|(?=%$))(.+)$/i relation = relation.where("SourcePattern(lower(posts.source)) NOT LIKE lower(?) ESCAPE E'\\\\'", "pixiv/" + $1) has_constraints! else diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index a15a73e2b..12c4249f3 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -1218,6 +1218,8 @@ class PostTest < ActiveSupport::TestCase post = FactoryGirl.create(:post, :source => url) assert_equal(1, Post.tag_match("source:*.pixiv.net/img*/artist-name/*").count) assert_equal(0, Post.tag_match("source:*.pixiv.net/img*/artist-fake/*").count) + assert_equal(1, Post.tag_match("source:http://*.pixiv.net/img*/img/artist-name/*").count) + assert_equal(0, Post.tag_match("source:http://*.pixiv.net/img*/img/artist-fake/*").count) assert_equal(1, Post.tag_match("source:pixiv/artist-name/*").count) assert_equal(0, Post.tag_match("source:pixiv/artist-fake/*").count) end