licurideprecated

Compliant data:uri parser

Usage no npm install needed!

<script type="module">
  import licuri from 'https://cdn.skypack.dev/licuri';
</script>

README

Licuri

Licuri palm seeds

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.

Install

$ npm install --save licuri

Build

$ git clone git://github.com/passcod/licuri
$ cd licuri
$ npm run build

Use

var licuri = require('licuri');

var uri = licuri.parse('data:,foobar');
console.log(uri.data); //=> "foobar"

Returned object synopsis

{
  "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"
    }
  }
}

Community

  • Released in the Public Domain
  • PRs and issue/bug reports welcome