Socket
Socket
Sign inDemoInstall

body-parser

Package Overview
Dependencies
5
Maintainers
6
Versions
72
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.1.2

5

HISTORY.md

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

1.1.2 / 2014-05-11
==================
* improve json parser speed
1.1.1 / 2014-05-11

@@ -2,0 +7,0 @@ ==================

25

index.js

@@ -8,2 +8,4 @@

var firstcharRegExp = /^\s*(.)/
exports = module.exports = bodyParser;

@@ -59,16 +61,19 @@ exports.json = json;

encoding: 'utf8'
}, function (err, buf) {
}, function (err, str) {
if (err) return next(err);
var first = buf.trim()[0];
if (0 == buf.length) {
if (0 == str.length) {
return next(error(400, 'invalid json, empty body'));
}
if (strict && '{' != first && '[' != first) return next(error(400, 'invalid json'));
var first = firstchar(str)
if (strict && '{' != first && '[' != first) {
return next(error(400, 'invalid json'));
}
try {
req.body = JSON.parse(buf, options.reviver);
req.body = JSON.parse(str, options.reviver);
} catch (err){
err.body = buf;
err.body = str;
err.status = 400;

@@ -125,1 +130,7 @@ return next(err);

}
function firstchar(str) {
if (!str) return ''
var match = firstcharRegExp.exec(str)
return match ? match[1] : ''
}
{
"name": "body-parser",
"description": "Node.js body parsing middleware",
"version": "1.1.1",
"version": "1.1.2",
"author": {

@@ -6,0 +6,0 @@ "name": "Jonathan Ong",

@@ -60,2 +60,4 @@ # body-parser [![Build Status](https://travis-ci.org/expressjs/body-parser.svg?branch=master)](https://travis-ci.org/expressjs/body-parser) [![NPM version](https://badge.fury.io/js/body-parser.svg)](https://badge.fury.io/js/body-parser)

The `reviver` argument is passed directly to `JSON.parse` as the second argument. You can find more information on this argument [in the MDN documentation about JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter).
### bodyParser.urlencoded(options)

@@ -62,0 +64,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc