diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/filters.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index 3a69131ea0..0329fbb8d4 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -11,12 +11,14 @@ module ActiveSupport #:nodoc: # string }.squish # => "Multi-line string" # " foo bar \n \t boo".squish # => "foo bar boo" def squish - strip.gsub(/\s+/, ' ') + dup.squish! end # Performs a destructive squish. See String#squish. def squish! - replace(squish) + strip! + gsub!(/\s+/, ' ') + self end end end |