about summary refs log tree commit diff
path: root/app/lib/formatter.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-02-05 15:29:16 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-02-05 15:29:16 +0100
commit6fa4e01139a8420d96f9a3c1fcf2b3c5bd0b38a9 (patch)
treed0eb78cae5d4be495f3e825f2dbe64899823cf0b /app/lib/formatter.rb
parent87830f99e7e47f19ce9368cca93b66a8c1c34517 (diff)
Fix showing ellipsis even when link hasn't been cut off
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r--app/lib/formatter.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index ff2a16f1b..044407a6c 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -68,8 +68,9 @@ class Formatter
     prefix = url.match(/\Ahttps?:\/\/(www\.)?/).to_s
     text   = url[prefix.length, 30]
     suffix = url[prefix.length + 30..-1]
+    cutoff = url[prefix.length..-1].length > 30
 
-    "<a rel=\"nofollow noopener\" target=\"_blank\" href=\"#{url}\"><span class=\"invisible\">#{prefix}</span><span class=\"ellipsis\">#{text}</span><span class=\"invisible\">#{suffix}</span></a>"
+    "<a rel=\"nofollow noopener\" target=\"_blank\" href=\"#{url}\"><span class=\"invisible\">#{prefix}</span><span class=\"#{cutoff ? 'ellipsis' : ''}\">#{text}</span><span class=\"invisible\">#{suffix}</span></a>"
   end
 
   def hashtag_html(match)