lib/active_support/base64.rb in activesupport-2.3.18 vs lib/active_support/base64.rb in activesupport-3.0.0.beta
- old
+ new
@@ -28,6 +28,15 @@
def self.decode64(data)
data.unpack("m").first
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