aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/text_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers/text_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb8
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