{"id":18429640,"url":"https://github.com/jsdom/data-urls","last_synced_at":"2026-01-20T05:01:03.463Z","repository":{"id":27409661,"uuid":"113771615","full_name":"jsdom/data-urls","owner":"jsdom","description":"Parse data: URLs","archived":false,"fork":false,"pushed_at":"2026-01-02T07:21:56.000Z","size":406,"stargazers_count":75,"open_issues_count":1,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-08T04:17:43.562Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsdom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"tidelift":"npm/jsdom"}},"created_at":"2017-12-10T18:03:54.000Z","updated_at":"2026-01-02T07:21:51.000Z","dependencies_parsed_at":"2023-11-11T08:29:37.827Z","dependency_job_id":"cb2e3456-9d24-48e8-ad41-946887d48bf5","html_url":"https://github.com/jsdom/data-urls","commit_stats":{"total_commits":31,"total_committers":4,"mean_commits":7.75,"dds":0.09677419354838712,"last_synced_commit":"55b4e54384921231893545e2c592afdb5685a986"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/jsdom/data-urls","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fdata-urls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fdata-urls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fdata-urls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fdata-urls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsdom","download_url":"https://codeload.github.com/jsdom/data-urls/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fdata-urls/sbom","scorecard":{"id":537998,"data":{"date":"2025-08-11","repo":{"name":"github.com/jsdom/data-urls","commit":"3ee6d206c41247593507d3870accef2c9e950e60"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Code-Review","score":0,"reason":"Found 2/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/jsdom/data-urls/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/jsdom/data-urls/build.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/jsdom/.github/SECURITY.md:1","Info: Found linked content: github.com/jsdom/.github/SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/jsdom/.github/SECURITY.md:1","Info: Found text in security policy: github.com/jsdom/.github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T07:28:56.331Z","repository_id":27409661,"created_at":"2025-08-20T07:28:56.331Z","updated_at":"2025-08-20T07:28:56.331Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28596087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-06T05:18:01.013Z","updated_at":"2026-01-20T05:01:03.453Z","avatar_url":"https://github.com/jsdom.png","language":"JavaScript","funding_links":["https://tidelift.com/funding/github/npm/jsdom"],"categories":[],"sub_categories":[],"readme":"# Parse `data:` URLs\n\nThis package helps you parse `data:` URLs [according to the WHATWG Fetch Standard](https://fetch.spec.whatwg.org/#data-urls):\n\n```js\nconst parseDataURL = require(\"data-urls\");\n\nconst textExample = parseDataURL(\"data:,Hello%2C%20World!\");\nconsole.log(textExample.mimeType.toString()); // \"text/plain;charset=US-ASCII\"\nconsole.log(textExample.body);                // Uint8Array(13) [ 72, 101, 108, 108, 111, 44, … ]\n\nconst htmlExample = parseDataURL(\"data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E\");\nconsole.log(htmlExample.mimeType.toString()); // \"text/html\"\nconsole.log(htmlExample.body);                // Uint8Array(22) [ 60, 104, 49, 62, 72, 101, … ]\n\nconst pngExample = parseDataURL(\"data:image/png;base64,iVBORw0KGgoAAA\" +\n                                \"ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4\" +\n                                \"//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU\" +\n                                \"5ErkJggg==\");\nconsole.log(pngExample.mimeType.toString()); // \"image/png\"\nconsole.log(pngExample.body);                // Uint8Array(85) [ 137, 80, 78, 71, 13, 10, … ]\n```\n\n## API\n\nThis package's main module's default export is a function that accepts a string and returns a `{ mimeType, body }` object, or `null` if the result cannot be parsed as a `data:` URL.\n\n- The `mimeType` property is an instance of [whatwg-mimetype](https://www.npmjs.com/package/whatwg-mimetype)'s `MIMEType` class.\n- The `body` property is a `Uint8Array` instance.\n\nAs shown in the examples above, you can easily get a stringified version of the MIME type using its `toString()` method. Read on for more on getting the stringified version of the body.\n\n### Decoding the body\n\nTo decode the body bytes of a parsed data URL, you'll need to use the `charset` parameter of the MIME type, if any. This contains an encoding [label](https://encoding.spec.whatwg.org/#label); there are [various possible labels](https://encoding.spec.whatwg.org/#names-and-labels) for a given encoding. You can use the [`TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) API for this:\n\n```js\nconst parseDataURL = require(\"data-urls\");\n\nconst dataURL = parseDataURL(arbitraryString);\n\n// If there's no charset parameter, e.g. if `arbitraryString` is `\"data:text/plain,H%C3%A9llo!\"`,\n// then let's guess UTF-8.\nconst encodingLabel = dataURL.mimeType.parameters.get(\"charset\") ?? \"utf-8\";\nconst decoder = new TextDecoder(encodingLabel);\n\nconst bodyDecoded = decoder.decode(dataURL.body);\n```\n\n(Note that as of the time of this writing in 2026-01, Node.js's built-in `TextDecoder` has many correctness bugs, so we suggest using the polyfill from the [`@exodus/bytes`](https://www.npmjs.com/package/@exodus/bytes) package until they are fixed.)\n\nUsing the parsed charset is quite important, since [the spec requires](https://fetch.spec.whatwg.org/#data-url-processor) that if no parseable MIME type is given, the default is `\"US-ASCII\"`, [aka windows-1252](https://encoding.spec.whatwg.org/#note-latin1-ascii)—not UTF-8, like you might asume. So for example, given an `arbitraryString` of `\"data:,H%E9llo!\"`, the above code snippet will correctly produce a `bodyDecoded` of `\"Héllo!\"` by using the windows-1252 decoder, whereas if you used a UTF-8 decoder you'd get back `\"H�llo!\"`.\n\n### Advanced functionality: parsing from a URL record\n\nIf you are using the [`whatwg-url`](https://www.npmjs.com/package/whatwg-url) package, you may already have a \"URL record\" object on hand, as produced by that package's `parseURL` export. In that case, you can use this package's `fromURLRecord` export to save a bit of work:\n\n```js\nconst { parseURL } = require(\"whatwg-url\");\nconst dataURLFromURLRecord = require(\"data-urls\").fromURLRecord;\n\nconst urlRecord = parseURL(\"data:,Hello%2C%20World!\");\nconst dataURL = dataURLFromURLRecord(urlRecord);\n```\n\nIn practice, we expect this functionality only to be used by consumers like [jsdom](https://www.npmjs.com/package/jsdom), which are using these packages at a very low level.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdom%2Fdata-urls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsdom%2Fdata-urls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdom%2Fdata-urls/lists"}