![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
media-type
Advanced tools
Readme
Node.js module to parse and validate RFC6838 media types.
Useful for parsing Content-Type
HTTP response headers
from HATEOAS constrained services.
Aware of vendor subtype trees, +suffixes, wildcards and semicolon delimited parameters.
npm install media-type
var mediaType = require('media-type');
var media = mediaType.fromString('text/plain');
if (media.isValid()) {
console.log(media.type); // 'text'
console.log(media.subtype); // 'plain'
console.log(media.hasSuffix()); // false
console.log(media.asString()); // 'text/plain'
console.log(media); // { type: 'text', subtype: 'plain', subtypeFacets: [ 'plain' ] ... }
}
var media = mediaType.fromString('application/vnd.company.app.entity-v2+xml; charset=utf8; BOM=true');
if (media.isValid()) {
console.log(media.type); // 'application'
console.log(media.subtype); // 'vnd.company.app.entity-v2'
console.log(media.subtypeFacets); // ['vnd', 'company', 'app', 'entity-v2']
console.log(media.hasSuffix()); // true
console.log(media.suffix); // 'xml'
console.log(media.parameters); // {charset: 'utf8', bom: 'true'}
console.log(media.isVendor()); // true
console.log(media.isPersonal()); // false
console.log(media.isExperimental()); // false
console.log(media.asString()); // 'application/vnd.company.app.entity-v2+xml;bom=true;charset=utf8'
console.log(media); // { type: 'application', subtype: 'vnd.company.app.entity-v2',
// subtypeFacets: [ 'vnd', 'company', 'app', 'entity-v2' ],
// suffix: 'xml', parameters: { charset: 'utf8', bom: 'true' } }
}
Factory method to construct an Object from a String representation of a media type.
Is this media type valid?
Return media type as a normalised String.
Does the media type have a suffix, e.g. the xml
of image/svg+xml
?
Does the media type have a vendor prefix, e.g. text/vnd.DMClientScript
?
Does the media type have a personal prefix, e.g. text/prs.lines.tag
?
Does the media type have an experimental prefix, e.g. text/x-test
?
Run the unit tests with:
npm test
Copyright 2013, 2014, 2015 Lovell Fuller and contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
FAQs
Parse and validate RFC6838 media types, anything from 'text/plain' to 'application/vnd.company.app.entity-v2+xml;charset=utf8'
The npm package media-type receives a total of 18,762 weekly downloads. As such, media-type popularity was classified as popular.
We found that media-type demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.