diff options
author | Michael Koziarski <michael@koziarski.com> | 2006-10-12 21:13:05 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2006-10-12 21:13:05 +0000 |
commit | 41c362352433f265a95c00d8e7b5c1f1299e9011 (patch) | |
tree | ef84b72d406c22c8764d19a5ee7db52481bc18b1 /actionpack/lib/action_view | |
parent | 48cef84150d2c5f7be351787d0584626f5b8155a (diff) | |
download | rails-41c362352433f265a95c00d8e7b5c1f1299e9011.tar.gz rails-41c362352433f265a95c00d8e7b5c1f1299e9011.tar.bz2 rails-41c362352433f265a95c00d8e7b5c1f1299e9011.zip |
Use String#chars in TextHelper::excerpt. Closes #6386 [Manfred Stienstra]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5288 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 27e093a1c3..0e142cbaff 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -45,14 +45,14 @@ module ActionView if text.nil? || phrase.nil? then return end phrase = Regexp.escape(phrase) - if found_pos = text =~ /(#{phrase})/i + if found_pos = text.chars =~ /(#{phrase})/i start_pos = [ found_pos - radius, 0 ].max - end_pos = [ found_pos + phrase.length + radius, text.length ].min + end_pos = [ found_pos + phrase.chars.length + radius, text.chars.length ].min prefix = start_pos > 0 ? excerpt_string : "" - postfix = end_pos < text.length ? excerpt_string : "" + postfix = end_pos < text.chars.length ? excerpt_string : "" - prefix + text[start_pos..end_pos].strip + postfix + prefix + text.chars[start_pos..end_pos].strip + postfix else nil end |