Skip to content

Commit 4aa23ab

Browse files
committed
Use unavatar.now.sh service to avoid avator rot
1 parent 7ec7bc6 commit 4aa23ab

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/transformative/view_helper.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,13 @@ def link_hashtags_twitter(content)
242242

243243
def force_https_author_profile(photo_url, base_url)
244244
url = URI.join(base_url, photo_url).to_s
245-
if url.start_with?('http://pbs.twimg.com')
246-
url.gsub 'http://pbs.twimg.com', 'https://pbs.twimg.com'
245+
# use unavatar.now.sh to avoid avatar rot
246+
if url.match(/pbs\.twimg\.com/)
247+
screen_name = base_url.split('/').last
248+
return "https://unavatar.now.sh/twitter/#{screen_name}"
249+
elsif url.match(/cdninstagram\.com/)
250+
screen_name = base_url.split('/')[3]
251+
return "https://unavatar.now.sh/instagram/#{screen_name}"
247252
end
248253
https_image(url)
249254
end

0 commit comments

Comments
 (0)