Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
};
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);
};
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);
};
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);
};
function normalizeType (value) {
// parse the type
var type = typer.parse(value)
// remove the parameters
type.parameters = undefined
// reformat it
return typer.format(type)
}
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);
};
function normalizeMimeType (mime) {
if (mime === 'binary') {
mime = 'application/octet-stream';
}
const contentType = mimeTypes.contentType(mime) || mime;
const parsed = mediaTyper.parse(contentType);
return mediaTyper.format(_.pick(parsed, [
'type',
'subtype',
'suffix'
]));
}
function typenormalize(value) {
try {
var type = typer.parse(value)
delete type.parameters
return typer.format(type)
} catch (err) {
return null
}
}
[
JsonSchema,
(expected, actual) => {
return isJson(actual) && isJsonSchema(expected);
},
'json'
],
[JsonExample, both(isJson), 'json']
];
const validator = validators.find(([_name, predicate]) => {
return predicate(expectedType, actualType);
});
if (!validator) {
const error = `Can't validate actual media type '${mediaTyper.format(
actualType
)}' against the expected media type '${mediaTyper.format(expectedType)}'.`;
return [error, null, null];
}
return [null, validator[0], validator[2]];
}