X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9a9b045372a6f48420a9a6dacfde52c34ab7abce..ca5de5b4e01297b07ce3a9db45e908f15f7cda11:/lib/rich_text.rb diff --git a/lib/rich_text.rb b/lib/rich_text.rb index 7325a2a28..9e43ed29c 100644 --- a/lib/rich_text.rb +++ b/lib/rich_text.rb @@ -25,15 +25,15 @@ module RichText doc = Nokogiri::HTML(to_html) - if doc.content.length > 0 + if doc.content.empty? + link_proportion = 0 + else doc.xpath("//a").each do |link| link_count += 1 link_size += link.content.length end link_proportion = link_size.to_f / doc.content.length.to_f - else - link_proportion = 0 end [link_proportion - 0.2, 0.0].max * 200 + link_count * 40