post_to_twitter: guess anything with a dot and up to 10 letters is a domain

This commit is contained in:
joshua stein 2016-02-17 14:21:56 -06:00
parent 0f498d3ee3
commit 9d371b72d6

View file

@ -46,7 +46,7 @@ Time.now - 1.days).order(:id).each_with_index do |s,x|
# if there are any urls in the title, they should be sized (at least) to a
# twitter t.co url
left_len -= (title.scan(/[^ ]\.(com|org|net|edu)/i).map{|u| [ 0,
left_len -= (title.scan(/[^ ]\..{2,10}/i).map{|u| [ 0,
Twitter::TCO_LEN ].max }.inject(:+)).to_i
if title.bytesize > left_len