sources: simplify artist finder url normalization.
Get rid of `normalized_for_artist_finder?` and `normalizable_for_artist_finder?`. This was legacy bullshit that was originally designed to avoid API calls when saving artist entries containing old Pixiv direct image urls that had already been normalized, or that couldn't be normalized because they were bad id. Nowadays we store profile urls in artist entries instead of direct image urls, so we don't normally need to do any API calls to normalize the profile url. Strategies should take care to avoid triggering API calls inside `profile_url` when possible.
This commit is contained in:
@@ -33,16 +33,7 @@ class ArtistUrl < ApplicationRecord
|
||||
# the strategy won't always work for twitter because it looks for a status
|
||||
url = url.downcase if url =~ %r!^https?://(?:mobile\.)?twitter\.com!
|
||||
|
||||
begin
|
||||
source = Sources::Strategies.find(url)
|
||||
|
||||
if !source.normalized_for_artist_finder? && source.normalizable_for_artist_finder?
|
||||
url = source.normalize_for_artist_finder
|
||||
end
|
||||
rescue Net::OpenTimeout, PixivApiClient::Error
|
||||
raise if Rails.env.test?
|
||||
end
|
||||
|
||||
url = Sources::Strategies.find(url).normalize_for_artist_finder
|
||||
url = url.gsub(/\/+\Z/, "")
|
||||
url = url.gsub(%r!^https://!, "http://")
|
||||
url + "/"
|
||||
|
||||
Reference in New Issue
Block a user