ekampp / strict-data-uri

Strict Data URI gem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Strict Data URI gem

License:MIT License


Languages

Language:Ruby 97.4%Language:Shell 2.6%