aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/base64.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/base64.rb')
-rw-r--r--activesupport/lib/active_support/base64.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb
index acb8e5a967..b8c01628ce 100644
--- a/activesupport/lib/active_support/base64.rb
+++ b/activesupport/lib/active_support/base64.rb
@@ -30,4 +30,13 @@ module ActiveSupport
end
end
end
+
+ # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters
+ # or memcache keys without further processing.
+ #
+ # ActiveSupport::Base64.encode64s("Original unencoded string")
+ # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw=="
+ def Base64.encode64s(value)
+ encode64(value).gsub(/\n/, '')
+ end
end