0.0
The project is in a healthy, maintained state
En/decodes Data-URI without newlines in the base64 encoded string
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies
 Project Readme

Strict::Data::Uri

This en- and decodes data URIs.

This was inspired by data-uri. The main difference being (a) more precise error handling and (b) using Ruby's Base64.strict_encode64 instead of Base64.encode64 which prevents the addition of newline (\n) characters every 60 characters in the encoded string.

Installation

Add this line to your application's Gemfile:

gem 'strict-data-uri'

And then execute:

bundle install

Usage

Encode a string into a data URI:

Strict::Data::Uri.encode "string"
# => data:text/plain;base64,c3RyaW5n

Decode a data URI:

Strict::Data::Uri.decode "data:text/plain;base64,c3RyaW5n"
# => string

Testing

To run the tests:

bundle exec rake

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/strict-data-uri.

License

The gem is available as open source under the terms of the MIT License.