Permalink
Browse files

Correct shorten url for even length urls

  • Loading branch information...
1 parent cf1b3c2 commit 1bec3904e126cb151252ccbc44fac012402d99a0 Alex Bredariol Grilo committed Oct 20, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 app/helpers/application_helper.rb
@@ -323,7 +323,7 @@ def shorten_url(url)
relevant_path = lambda do |uri|
request_uri =
uri.to_s[((uri.scheme.to_s + uri.host.to_s).to_s.length + 3)..-1].to_s
- head = truncate(request_uri[0..(request_uri.length / 2)], :length => 30)
+ head = truncate(request_uri[0..(request_uri.length / 2.0).ceil - 1], :length => 30)
tail = truncate(request_uri.reverse[0..(request_uri.length / 2) - 1],
:length => 30).reverse
(head + tail).sub('......', '...').squeeze('/')

0 comments on commit 1bec390

Please sign in to comment.