fixes #3422
This commit is contained in:
@@ -16,6 +16,10 @@ class ArtistUrl < ApplicationRecord
|
||||
url = url.gsub(/^http:\/\/blog-imgs-\d+-\w+\.fc2/, "http://blog.fc2")
|
||||
url = url.sub(%r!(http://seiga.nicovideo.jp/user/illust/\d+)\?.+!, '\1/')
|
||||
url = url.sub(%r!^http://pictures.hentai-foundry.com//!, "http://pictures.hentai-foundry.com/")
|
||||
|
||||
# the strategy won't always work for twitter because it looks for a status
|
||||
url = url.downcase if url =~ /https?:\/\/(?:mobile\.)?twitter\.com/
|
||||
|
||||
begin
|
||||
url = Sources::Site.new(url).normalize_for_artist_finder!
|
||||
rescue PixivApiClient::Error, Sources::Site::NoStrategyError
|
||||
|
||||
@@ -3,6 +3,7 @@ require 'test_helper'
|
||||
class ArtistUrlTest < ActiveSupport::TestCase
|
||||
context "An artist url" do
|
||||
setup do
|
||||
User.any_instance.stubs(:validate_sock_puppets)
|
||||
CurrentUser.user = FactoryGirl.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
@@ -28,6 +29,16 @@ class ArtistUrlTest < ActiveSupport::TestCase
|
||||
assert_equal("http://google.com/", url.normalized_url)
|
||||
end
|
||||
|
||||
context "normalize twitter profile urls" do
|
||||
setup do
|
||||
@url = FactoryGirl.create(:artist_url, :url => "https://twitter.com/BLAH")
|
||||
end
|
||||
|
||||
should "downcase the url" do
|
||||
assert_equal("http://twitter.com/blah/", @url.normalized_url)
|
||||
end
|
||||
end
|
||||
|
||||
should "normalize fc2 urls" do
|
||||
url = FactoryGirl.create(:artist_url, :url => "http://blog55.fc2.com/monet")
|
||||
assert_equal("http://blog55.fc2.com/monet", url.url)
|
||||
|
||||
@@ -158,15 +158,5 @@ module Sources
|
||||
assert_equal(tags, @site.tags)
|
||||
end
|
||||
end
|
||||
|
||||
context "#normalize_for_artist_finder!" do
|
||||
setup do
|
||||
@site = Sources::Site.new("https://twitter.com/BLAH")
|
||||
end
|
||||
|
||||
should "downcase the url" do
|
||||
assert_equal("https://twitter.com/blah", @site.normalize_for_artist_finder!)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user