{"id":16049027,"url":"https://github.com/lovell/media-type","last_synced_at":"2025-09-07T04:37:04.431Z","repository":{"id":11733313,"uuid":"14258498","full_name":"lovell/media-type","owner":"lovell","description":"JavaScript module to parse and validate RFC6838 media types, anything from 'text/plain' to 'application/vnd.company.app.entity-v2+xml;charset=utf8'","archived":false,"fork":false,"pushed_at":"2017-04-05T21:02:12.000Z","size":20,"stargazers_count":15,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-09T10:45:10.936Z","etag":null,"topics":["content-type","hateoas","http","javascript","nodejs","rfc-6838"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-09T14:32:39.000Z","updated_at":"2022-05-04T04:04:55.000Z","dependencies_parsed_at":"2022-07-07T12:40:19.588Z","dependency_job_id":null,"html_url":"https://github.com/lovell/media-type","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/lovell/media-type","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Fmedia-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Fmedia-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Fmedia-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Fmedia-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovell","download_url":"https://codeload.github.com/lovell/media-type/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovell%2Fmedia-type/sbom","scorecard":{"id":600106,"data":{"date":"2025-08-11","repo":{"name":"github.com/lovell/media-type","commit":"43488903b66ecc3acc358708c68b78f6805ecc94"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"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":"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":"Code-Review","score":1,"reason":"Found 2/13 approved changesets -- score normalized to 1","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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 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-21T00:11:52.368Z","repository_id":11733313,"created_at":"2025-08-21T00:11:52.368Z","updated_at":"2025-08-21T00:11:52.368Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273501967,"owners_count":25117092,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["content-type","hateoas","http","javascript","nodejs","rfc-6838"],"created_at":"2024-10-09T00:12:37.594Z","updated_at":"2025-09-07T04:37:04.383Z","avatar_url":"https://github.com/lovell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# media-type\n\nNode.js module to parse and validate\n[RFC6838](http://tools.ietf.org/html/rfc6838) media types.\n\nUseful for parsing `Content-Type` HTTP response headers\nfrom [HATEOAS](http://en.wikipedia.org/wiki/HATEOAS) constrained services.\n\nAware of vendor subtype trees, +suffixes, wildcards and semicolon delimited parameters.\n\n## Install\n\n    npm install media-type\n\n## Usage examples\n\n```javascript\nvar mediaType = require('media-type');\n```\n\n```javascript\nvar media = mediaType.fromString('text/plain');\nif (media.isValid()) {\n  console.log(media.type);        // 'text'\n  console.log(media.subtype);     // 'plain'\n  console.log(media.hasSuffix()); // false\n  console.log(media.asString());  // 'text/plain'\n  console.log(media);             // { type: 'text', subtype: 'plain', subtypeFacets: [ 'plain' ] ... }\n}\n```\n\n```javascript\nvar media = mediaType.fromString('application/vnd.company.app.entity-v2+xml; charset=utf8; BOM=true');\nif (media.isValid()) {\n  console.log(media.type);             // 'application'\n  console.log(media.subtype);          // 'vnd.company.app.entity-v2'\n  console.log(media.subtypeFacets);    // ['vnd', 'company', 'app', 'entity-v2']\n  console.log(media.hasSuffix());      // true\n  console.log(media.suffix);           // 'xml'\n  console.log(media.parameters);       // {charset: 'utf8', bom: 'true'}\n  console.log(media.isVendor());       // true\n  console.log(media.isPersonal());     // false\n  console.log(media.isExperimental()); // false\n  console.log(media.asString());       // 'application/vnd.company.app.entity-v2+xml;bom=true;charset=utf8'\n  console.log(media);                  // { type: 'application', subtype: 'vnd.company.app.entity-v2',\n                                       //   subtypeFacets: [ 'vnd', 'company', 'app', 'entity-v2' ],\n                                       //   suffix: 'xml', parameters: { charset: 'utf8', bom: 'true' } }\n}\n```\n\n## API\n\n### fromString(str)\n\nFactory method to construct an Object from a String representation of a media type.\n\n### isValid()\n\nIs this media type valid?\n\n### asString()\n\nReturn media type as a normalised String.\n\n### hasSuffix()\n\nDoes the media type have a suffix, e.g. the `xml` of `image/svg+xml`?\n\n### isVendor()\n\nDoes the media type have a vendor prefix, e.g. `text/vnd.DMClientScript`?\n\n### isPersonal()\n\nDoes the media type have a personal prefix, e.g. `text/prs.lines.tag`?\n\n### isExperimental()\n\nDoes the media type have an experimental prefix, e.g. `text/x-test`?\n\n## Test [![Build Status](https://travis-ci.org/lovell/media-type.png?branch=master)](https://travis-ci.org/lovell/media-type)\n\nRun the unit tests with:\n\n    npm test\n\n## Licence\n\nCopyright 2013, 2014, 2015 Lovell Fuller and contributors\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovell%2Fmedia-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovell%2Fmedia-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovell%2Fmedia-type/lists"}