fixes #2718: Twitter artist finding should not be case sensitive
This commit is contained in:
@@ -38,6 +38,14 @@ module Sources::Strategies
|
|||||||
TwitterService.new.image_urls(url)
|
TwitterService.new.image_urls(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize_for_artist_finder!
|
||||||
|
url.downcase
|
||||||
|
end
|
||||||
|
|
||||||
|
def normalizable_for_artist_finder?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def status_id_from_url(url)
|
def status_id_from_url(url)
|
||||||
if url =~ %r{^https?://(?:mobile\.)?twitter\.com/\w+/status/(\d+)}
|
if url =~ %r{^https?://(?:mobile\.)?twitter\.com/\w+/status/(\d+)}
|
||||||
$1.to_i
|
$1.to_i
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ class ArtistUrl < ActiveRecord::Base
|
|||||||
if url.nil?
|
if url.nil?
|
||||||
nil
|
nil
|
||||||
else
|
else
|
||||||
url = url.downcase
|
|
||||||
url = url.gsub(/^https:\/\//, "http://")
|
url = url.gsub(/^https:\/\//, "http://")
|
||||||
url = url.gsub(/^http:\/\/blog\d+\.fc2/, "http://blog.fc2")
|
url = url.gsub(/^http:\/\/blog\d+\.fc2/, "http://blog.fc2")
|
||||||
url = url.gsub(/^http:\/\/blog-imgs-\d+\.fc2/, "http://blog.fc2")
|
url = url.gsub(/^http:\/\/blog-imgs-\d+\.fc2/, "http://blog.fc2")
|
||||||
@@ -45,7 +44,6 @@ class ArtistUrl < ActiveRecord::Base
|
|||||||
url = File.dirname(url)
|
url = File.dirname(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
url = url.downcase
|
|
||||||
url = url.gsub(/^https:\/\//, "http://")
|
url = url.gsub(/^https:\/\//, "http://")
|
||||||
url = url.gsub(/^http:\/\/blog\d+\.fc2/, "http://blog*.fc2")
|
url = url.gsub(/^http:\/\/blog\d+\.fc2/, "http://blog*.fc2")
|
||||||
url = url.gsub(/^http:\/\/blog-imgs-\d+\.fc2/, "http://blog*.fc2")
|
url = url.gsub(/^http:\/\/blog-imgs-\d+\.fc2/, "http://blog*.fc2")
|
||||||
|
|||||||
@@ -54,5 +54,11 @@ class ArtistUrlTest < ActiveSupport::TestCase
|
|||||||
assert_equal("http://img55.pixiv.net/img/monet", url.url)
|
assert_equal("http://img55.pixiv.net/img/monet", url.url)
|
||||||
assert_equal("http://img.pixiv.net/img/monet/", url.normalized_url)
|
assert_equal("http://img.pixiv.net/img/monet/", url.normalized_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "normalize twitter urls" do
|
||||||
|
url = FactoryGirl.create(:artist_url, :url => "https://twitter.com/MONET/status/12345")
|
||||||
|
assert_equal("https://twitter.com/MONET/status/12345", url.url)
|
||||||
|
assert_equal("http://twitter.com/monet/status/12345/", url.normalized_url)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user