How to use media-typer - 10 common examples

To help you get started, we’ve selected a few media-typer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Lapple / ErrorBoard / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github apiaryio / gavel.js / lib / mixins / validatable-http-message.js View on Github external
isJsonContentType(contentTypeValue) {
    if (!contentTypeValue) {
      return false;
    }
    try {
      const { type } = contentType.parse(`${contentTypeValue}`);
      const parsed = mediaTyper.parse(type);
      return (
        (parsed.type === 'application' && parsed.subtype === 'json') ||
        parsed.suffix === 'json'
      );
    } catch (e) {
      // The Content-Type value is basically a user input, it can be any
      // kind of rubbish, and it is neither this function's nor Gavel's problem
      // if it's invalid
      return false;
    }
  }
}
github alex-cory / fasthacks / Dev_Notes / JavaScript / nodejs / nodeJS examples / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github stimulant / ampm / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github ethereum / meteor-dapp-whisper-chat-client / dist / bundle / programs / server / npm / iron:router / node_modules / body-parser / lib / types / urlencoded.js View on Github external
return function urlencodedParser(req, res, next) {
    if (req._body) return next();
    req.body = req.body || {}

    if (!typeis(req, type)) return next();

    var charset = typer.parse(req).parameters.charset || 'utf-8'
    if (charset.toLowerCase() !== 'utf-8') {
      var err = new Error('unsupported charset')
      err.status = 415
      next(err)
      return
    }

    // read
    read(req, res, next, parse, {
      encoding: charset,
      inflate: inflate,
      limit: limit,
      verify: verify
    })
  }
}
github tejasmanohar / twilio-plays-2048 / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github tangdu / mblog / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github andrewshawcare / thoughtworks-email-signature-generator / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github dungeon-revealer / dungeon-revealer / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github jens-maus / RaspberryMatic / buildroot-external / package / neoserver / pkg / mediola / neo_server / node_modules / type-is / index.js View on Github external
function normalizeType (value) {
  // parse the type
  var type = typer.parse(value)

  // remove the parameters
  type.parameters = undefined

  // reformat it
  return typer.format(type)
}

media-typer

Simple RFC 6838 media type parser and formatter

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Popular media-typer functions