Socket
Socket
Sign inDemoInstall

data-uri-to-buffer

Package Overview
Dependencies
0
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 0.0.4

.travis.yml

9

History.md
0.0.4 / 2015-06-29
==================
* package: update "mocha" to v2
* package: add RFC to the "keywords" section
* travis: test node v0.8, v0.10, and v0.12
* README: use SVG for Travis-CI badge
* test: more tests
0.0.3 / 2014-01-08

@@ -3,0 +12,0 @@ ==================

8

package.json
{
"name": "data-uri-to-buffer",
"version": "0.0.3",
"version": "0.0.4",
"description": "Generate a Buffer instance from a Data URI string",

@@ -22,3 +22,5 @@ "main": "index.js",

"buffer",
"convert"
"convert",
"rfc2397",
"2397"
],

@@ -32,4 +34,4 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",

"devDependencies": {
"mocha": "~1.16.2"
"mocha": "2"
}
}
data-uri-to-buffer
==================
### Generate a Buffer instance from a Data URI string
[![Build Status](https://travis-ci.org/TooTallNate/data-uri-to-buffer.png?branch=master)](https://travis-ci.org/TooTallNate/data-uri-to-buffer)
### Generate a Buffer instance from a [Data URI][rfc] string
[![Build Status](https://travis-ci.org/TooTallNate/node-data-uri-to-buffer.svg?branch=master)](https://travis-ci.org/TooTallNate/node-data-uri-to-buffer)
This module accepts a ["data" URI][rfc] String of data, and returns a
node.js `Buffer` instance with the decoded data.

@@ -23,2 +25,14 @@

var dataUriToBuffer = require('data-uri-to-buffer');
// plain-text data is supported
var uri = 'data:,Hello%2C%20World!';
var decoded = dataUriToBuffer(uri);
console.log(decoded.toString());
// 'Hello, World!'
// base64-encoded data is supported
uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
decoded = dataUriToBuffer(uri);
console.log(decoded.toString());
// 'Hello, World!'
```

@@ -32,4 +46,11 @@

The `type` property on the Buffer instance gets set to the Content-Type portion of
the "mediatype" portion of the "data" URI, or defaults to `"text/plain"` if not
specified.
The `charset` property on the Buffer instance gets set to the Charset portion of
the "mediatype" portion of the "data" URI, or defaults to `"US-ASCII"` if not
specified.
License

@@ -60,1 +81,3 @@ -------

SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[rfc]: http://tools.ietf.org/html/rfc2397

@@ -114,3 +114,3 @@

it('should take "data" segment after the first comma', function () {
it('should decode data with a "," comma char', function () {
var uri = 'data:,a,b';

@@ -122,2 +122,9 @@ var buf = dataUriToBuffer(uri);

it('should decode data with traditionally reserved characters like ";"', function () {
var uri = 'data:,;test';
var buf = dataUriToBuffer(uri);
assert.equal('text/plain', buf.type);
assert.equal(';test', buf.toString());
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc