Fix #3738: Artist URL search should be case-insensitive for domains.
This commit is contained in:
@@ -19,6 +19,7 @@ class ArtistUrl < ApplicationRecord
|
||||
nil
|
||||
else
|
||||
url = url.sub(%r!^https://!, "http://")
|
||||
url = url.sub(%r!^http://([^/]+)!i) { |domain| domain.downcase }
|
||||
url = url.sub(%r!^http://blog\d+\.fc2!, "http://blog.fc2")
|
||||
url = url.sub(%r!^http://blog-imgs-\d+\.fc2!, "http://blog.fc2")
|
||||
url = url.sub(%r!^http://blog-imgs-\d+-\w+\.fc2!, "http://blog.fc2")
|
||||
|
||||
@@ -205,6 +205,11 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
assert_equal(["minko"], Artist.find_all_by_url("http://minko.com/x/test.jpg").map(&:name))
|
||||
end
|
||||
|
||||
should "be case-insensitive to domains when finding matches by url" do
|
||||
a1 = FactoryBot.create(:artist, name: "bkub", url_string: "http://BKUB.example.com")
|
||||
assert_artist_found(a1.name, "http://bkub.example.com")
|
||||
end
|
||||
|
||||
should "not find duplicates" do
|
||||
FactoryBot.create(:artist, :name => "warhol", :url_string => "http://warhol.com/x/a/image.jpg\nhttp://warhol.com/x/b/image.jpg")
|
||||
assert_equal(["warhol"], Artist.find_all_by_url("http://warhol.com/x/test.jpg").map(&:name))
|
||||
|
||||
@@ -35,6 +35,11 @@ class ArtistUrlTest < ActiveSupport::TestCase
|
||||
assert_equal("http://google.com/", url.normalized_url)
|
||||
end
|
||||
|
||||
should "normalise domains to lowercase" do
|
||||
url = FactoryBot.create(:artist_url, url: "https://ArtistName.example.com")
|
||||
assert_equal("http://artistname.example.com/", url.normalized_url)
|
||||
end
|
||||
|
||||
context "normalize twitter profile urls" do
|
||||
setup do
|
||||
@url = FactoryBot.create(:artist_url, :url => "https://twitter.com/BLAH")
|
||||
|
||||
Reference in New Issue
Block a user