Compliant data:uri parser
Uses an actual grammar (PEG.js syntax) derived from the RFC instead of simple string operations and/or regex matching. Handles base64 and plain text, supports content-type parameters. No runtime dependencies.
$ npm install --save licuri
$ git clone git://github.com/passcod/licuri
$ cd licuri
$ npm run build
var licuri = require('licuri');
var uri = licuri.parse('data:,foobar');
console.log(uri.data); //=> "foobar"
{
"raw": "Raw data as given in the uri",
"data": "Decoded data, either from base64 or URL-encoding",
"base64": false, "(bool": "Whether the data was base64-encoded)",
"content": {
"type": "Default: text",
"subtype": "Default: plain",
"params": {
"Any": "parameter",
"attached": "to",
"the": "content-type"
}
}
}
- Released in the Public Domain
- PRs and issue/bug reports welcome