Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

content

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

content - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

20

lib/index.js

@@ -0,4 +1,6 @@

'use strict';
// Load modules
var Boom = require('boom');
const Boom = require('boom');

@@ -8,3 +10,3 @@

var internals = {};
const internals = {};

@@ -27,3 +29,3 @@

var match = header.match(internals.contentTypeRegex);
const match = header.match(internals.contentTypeRegex);
if (!match) {

@@ -33,4 +35,4 @@ return Boom.badRequest('Invalid content-type header');

var mime = match[1].toLowerCase();
var boundary = match[2] || match[3];
const mime = match[1].toLowerCase();
const boundary = match[2] || match[3];
if (mime.indexOf('multipart/') === 0 &&

@@ -74,3 +76,3 @@ !boundary) {

var match = header.match(internals.contentDispositionRegex);
const match = header.match(internals.contentDispositionRegex);
if (!match) {

@@ -80,3 +82,3 @@ return Boom.badRequest('Invalid content-disposition header format');

var parameters = match[1];
const parameters = match[1];
if (!parameters) {

@@ -86,4 +88,4 @@ return Boom.badRequest('Invalid content-disposition header missing parameters');

var result = {};
var leftovers = parameters.replace(internals.contentDispositionParamRegex, function ($0, $1, $2, $3, $4, $5) {
const result = {};
const leftovers = parameters.replace(internals.contentDispositionParamRegex, ($0, $1, $2, $3, $4, $5) => {

@@ -90,0 +92,0 @@ if ($2) {

{
"name": "content",
"description": "HTTP Content-* headers parsing",
"version": "2.0.0",
"version": "3.0.0",
"repository": "git://github.com/hapijs/content",

@@ -15,10 +15,10 @@ "main": "lib/index.js",

"engines": {
"node": ">=4.2"
"node": ">=4.0.0"
},
"dependencies": {
"boom": "2.x.x"
"boom": "3.x.x"
},
"devDependencies": {
"lab": "6.x.x",
"code": "1.x.x"
"code": "2.x.x",
"lab": "7.x.x"
},

@@ -25,0 +25,0 @@ "scripts": {

@@ -0,6 +1,8 @@

'use strict';
// Load modules
var Code = require('code');
var Lab = require('lab');
var Content = require('..');
const Code = require('code');
const Lab = require('lab');
const Content = require('..');

@@ -10,3 +12,3 @@

var internals = {};
const internals = {};

@@ -16,13 +18,13 @@

var lab = exports.lab = Lab.script();
var describe = lab.describe;
var it = lab.it;
var expect = Code.expect;
const lab = exports.lab = Lab.script();
const describe = lab.describe;
const it = lab.it;
const expect = Code.expect;
describe('type()', function () {
describe('type()', () => {
it('parses header', function (done) {
it('parses header', (done) => {
var type = Content.type('application/json; some=property; and="another"');
const type = Content.type('application/json; some=property; and="another"');
expect(type.isBoom).to.not.exist();

@@ -34,5 +36,5 @@ expect(type.mime).to.equal('application/json');

it('parses header (only type)', function (done) {
it('parses header (only type)', (done) => {
var type = Content.type('application/json');
const type = Content.type('application/json');
expect(type.isBoom).to.not.exist();

@@ -44,5 +46,5 @@ expect(type.mime).to.equal('application/json');

it('parses header (boundary)', function (done) {
it('parses header (boundary)', (done) => {
var type = Content.type('application/json; boundary=abcdefghijklm');
const type = Content.type('application/json; boundary=abcdefghijklm');
expect(type.isBoom).to.not.exist();

@@ -54,5 +56,5 @@ expect(type.mime).to.equal('application/json');

it('parses header (quoted boundary)', function (done) {
it('parses header (quoted boundary)', (done) => {
var type = Content.type('application/json; boundary="abcdefghijklm"');
const type = Content.type('application/json; boundary="abcdefghijklm"');
expect(type.isBoom).to.not.exist();

@@ -64,5 +66,5 @@ expect(type.mime).to.equal('application/json');

it('errors on invalid header', function (done) {
it('errors on invalid header', (done) => {
var type = Content.type('application/json; some');
const type = Content.type('application/json; some');
expect(type.isBoom).to.exist();

@@ -72,5 +74,5 @@ done();

it('errors on multipart missing boundary', function (done) {
it('errors on multipart missing boundary', (done) => {
var type = Content.type('multipart/form-data');
const type = Content.type('multipart/form-data');
expect(type.isBoom).to.exist();

@@ -81,7 +83,7 @@ done();

describe('disposition()', function () {
describe('disposition()', () => {
it('parses header', function (done) {
it('parses header', (done) => {
var header = 'form-data; name="file"; filename=file.jpg';
const header = 'form-data; name="file"; filename=file.jpg';

@@ -92,5 +94,5 @@ expect(Content.disposition(header)).to.deep.equal({ name: 'file', filename: 'file.jpg' });

it('parses header (empty filename)', function (done) {
it('parses header (empty filename)', (done) => {
var header = 'form-data; name="file"; filename=""';
const header = 'form-data; name="file"; filename=""';

@@ -101,5 +103,5 @@ expect(Content.disposition(header)).to.deep.equal({ name: 'file', filename: '' });

it('handles language filename', function (done) {
it('handles language filename', (done) => {
var header = 'form-data; name="file"; filename*=utf-8\'en\'with%20space';
const header = 'form-data; name="file"; filename*=utf-8\'en\'with%20space';

@@ -110,5 +112,5 @@ expect(Content.disposition(header)).to.deep.equal({ name: 'file', filename: 'with space' });

it('errors on invalid language filename', function (done) {
it('errors on invalid language filename', (done) => {
var header = 'form-data; name="file"; filename*=steve';
const header = 'form-data; name="file"; filename*=steve';

@@ -119,5 +121,5 @@ expect(Content.disposition(header).message).to.equal('Invalid content-disposition header format includes invalid parameters');

it('errors on invalid format', function (done) {
it('errors on invalid format', (done) => {
var header = 'steve';
const header = 'steve';

@@ -128,3 +130,3 @@ expect(Content.disposition(header).message).to.equal('Invalid content-disposition header format');

it('errors on missing header', function (done) {
it('errors on missing header', (done) => {

@@ -135,5 +137,5 @@ expect(Content.disposition('').message).to.equal('Missing content-disposition header');

it('errors on missing parameters', function (done) {
it('errors on missing parameters', (done) => {
var header = 'form-data';
const header = 'form-data';

@@ -144,5 +146,5 @@ expect(Content.disposition(header).message).to.equal('Invalid content-disposition header missing parameters');

it('errors on missing language value', function (done) {
it('errors on missing language value', (done) => {
var header = 'form-data; name="file"; filename*=';
const header = 'form-data; name="file"; filename*=';

@@ -153,5 +155,5 @@ expect(Content.disposition(header).message).to.equal('Invalid content-disposition header format includes invalid parameters');

it('errors on invalid percent encoded language value', function (done) {
it('errors on invalid percent encoded language value', (done) => {
var header = 'form-data; name="file"; filename*=utf-8\'en\'with%vxspace';
const header = 'form-data; name="file"; filename*=utf-8\'en\'with%vxspace';

@@ -162,5 +164,5 @@ expect(Content.disposition(header).message).to.equal('Invalid content-disposition header format includes invalid parameters');

it('errors on missing name', function (done) {
it('errors on missing name', (done) => {
var header = 'form-data; filename=x';
const header = 'form-data; filename=x';

@@ -167,0 +169,0 @@ expect(Content.disposition(header).message).to.equal('Invalid content-disposition header missing name parameter');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc