{"id":19874424,"url":"https://github.com/strongloop/strong-data-uri","last_synced_at":"2025-05-02T10:31:07.235Z","repository":{"id":10561642,"uuid":"12764163","full_name":"strongloop/strong-data-uri","owner":"strongloop","description":"Parser and encoder for `data:` URIs","archived":false,"fork":false,"pushed_at":"2023-01-26T16:48:25.000Z","size":55,"stargazers_count":13,"open_issues_count":1,"forks_count":6,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-07T01:05:05.393Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strongloop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-11T18:31:53.000Z","updated_at":"2022-12-31T18:12:01.000Z","dependencies_parsed_at":"2023-02-14T19:46:21.923Z","dependency_job_id":null,"html_url":"https://github.com/strongloop/strong-data-uri","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-data-uri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-data-uri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-data-uri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Fstrong-data-uri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strongloop","download_url":"https://codeload.github.com/strongloop/strong-data-uri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251765535,"owners_count":21640196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T16:23:18.067Z","updated_at":"2025-05-02T10:31:06.966Z","avatar_url":"https://github.com/strongloop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strong-data-uri\n\n[![Build Status](https://travis-ci.org/strongloop/strong-data-uri.png?branch=master)](https://travis-ci.org/strongloop/strong-data-uri)\n[![NPM version](https://badge.fury.io/js/strong-data-uri.png)](http://badge.fury.io/js/strong-data-uri)\n\n## Overview\nstrong-data-uri implements a parser for retrieving data encoded\nin `data:` URIs specified by [RFC2397](http://www.ietf.org/rfc/rfc2397.txt),\nas well as an encoder for those URIs.\n\n## API\n\n - [decode](#decodeuri)\n - [encode](#encodedata-mediatype)\n\n### decode(uri)\n\nCall `dataUri.decode(uri)` to parse the payload of a data URI. The `uri`\nargument expects a string.\n\n```js\nvar dataUri = require('strong-data-uri');\nvar uri = 'data:text/plain;charset=iso-8859-1;base64,aGVsbG8gd29ybGQ=';\n\nvar buffer = dataUri.decode(uri);\nconsole.log(buffer);\n// \u003cBuffer 68 65 6c 6c 6f 20 77 6f 72 6c 64\u003e\nconsole.log(buffer.toString('ascii'));\n// Hello world\n\nconsole.log(buffer.mimetype);  // text/plain\nconsole.log(buffer.mediatype); // text/plain;charset=iso-8859-1\nconsole.log(buffer.charset);   // iso-8859-1\n```\n\n### encode(data, [mediatype])\n\nUse `dataUri.encode(data, mediatype)` to build a new data URI. The `data`\nargument can be a `Buffer` or a `String`. Strings are converted to buffers\nusing `utf-8` encoding.\n\nIf `mediatype` is not specified, then `application/octet-stream` is used\nas a default if the data is a Buffer, and `text/plain;charset=UTF-8` if\nthe data is a String.\n\n```js\nvar dataUri = require('strong-data-uri');\n\nuri = dataUri.encode('foo');\nconsole.log(uri);\n// data:text/plain;charset=UTF-8;base64,Zm9v\n\nuri = dataUri.encode(new Buffer('\u003cfoo/\u003e', 'utf8'), 'text/xml');\nconsole.log(uri);\n// data:text/xml;base64,PGZvby8+\n```\n\n## Command-line access\n\nTo keep this project small and light, no command-line tool is provided.  If you\nneed one, please consider [data-colon](https://github.com/hildjj/data-colon).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Fstrong-data-uri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrongloop%2Fstrong-data-uri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Fstrong-data-uri/lists"}