Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9eb5ab4
chore: add support for OSSF scorecard reporting (#522)
inigomarquinez May 14, 2024
1c2f923
Added support for external parsers to bodyParser.json()
Nov 21, 2017
2f4913c
removed test dependency on json-bigint
Nov 21, 2017
6daefb5
reworked doc to describe json parser() func better
Nov 21, 2017
b740295
added parser() option and doc for .text()
Nov 21, 2017
cf3a8e3
added parser() option and doc for .raw()
Nov 21, 2017
2468f72
added parser() option and doc for .urlencoded()
Nov 21, 2017
d75adee
cleanup to satisfy linter
Nov 21, 2017
8224cda
added generic parser
Nov 21, 2017
a5adc82
converted json parser to use generic parser
Nov 21, 2017
c572330
converted raw parser to use generic parser
Nov 21, 2017
7390c89
converted text parser to use generic parser
Nov 21, 2017
f4f9d84
converted urlencoded parser to use generic parser
Nov 21, 2017
10eb0af
cleanup / fix linter warnings
Nov 21, 2017
67060ca
removed items from README
Nov 21, 2017
e6f6004
added bodyParser.generic() getter
Nov 21, 2017
07e0602
cleanup / fix linter warnings
Nov 21, 2017
bb7697a
fixed tests after rebase
sdellysse Apr 17, 2020
6a7c24d
satisfying linter
sdellysse Apr 17, 2020
bc7454b
Ref'd genParser via the bodyparser getter to signal how third party p…
sdellysse Apr 17, 2020
519f306
removed dep on object-assign, which didnt support node < 0.10
sdellysse Apr 17, 2020
cdf46f0
minor text cleanup
sdellysse Apr 17, 2020
8ac04fd
🔧 add debug script
ctcpip May 24, 2024
1a43910
🐛 fix object merging
ctcpip May 24, 2024
86804fe
🔥 clean up
ctcpip May 24, 2024
88f84bd
💚 remove node < 4 from CI
ctcpip May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
satisfying linter
  • Loading branch information
sdellysse authored and ctcpip committed May 24, 2024
commit 6a7c24daa17133616b367ad9e1b63bc6f99b47ea
10 changes: 5 additions & 5 deletions lib/types/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var JSON_SYNTAX_REGEXP = /#+/g
* @public
*/

function json(options) {
function json (options) {
var opts = options || {}

var reviver = opts.reviver
Expand All @@ -58,11 +58,11 @@ function json(options) {
return genericParser(assign({}, opts, {
type: type,

charset: function validateCharset(charset) {
charset: function validateCharset (charset) {
return charset.slice(0, 4) === 'utf-'
},

parse: function parse(buf) {
parse: function parse (buf) {
if (buf.length === 0) {
// special-case empty json body, as it's a common client-side mistake
// TODO: maybe make this configurable or part of "strict" option
Expand Down Expand Up @@ -100,7 +100,7 @@ function json(options) {
* @private
*/

function createStrictSyntaxError(parser, reviver, str, char) {
function createStrictSyntaxError (parser, reviver, str, char) {
var index = str.indexOf(char)
var partial = ''

Expand Down Expand Up @@ -148,7 +148,7 @@ function firstchar (str) {
* @return {SyntaxError}
*/

function normalizeJsonSyntaxError(error, obj) {
function normalizeJsonSyntaxError (error, obj) {
var keys = Object.getOwnPropertyNames(error)

for (var i = 0; i < keys.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions lib/types/urlencoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function urlencoded (options) {

var queryparse = opts.parser || (
extended
? extendedparser(opts)
: simpleparser(opts)
? extendedparser(opts)
: simpleparser(opts)
)

return genericParser(assign({}, opts, {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}
}
8 changes: 4 additions & 4 deletions test/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ describe('bodyParser.json()', function () {
return { foo: 'bar' }
}
}))
.post('/')
.set('Content-Type', 'application/json')
.send('{"str":')
.expect(200, '{"foo":"bar"}', done)
.post('/')
.set('Content-Type', 'application/json')
.send('{"str":')
.expect(200, '{"foo":"bar"}', done)
})

describe('when JSON is invalid', function () {
Expand Down
8 changes: 4 additions & 4 deletions test/urlencoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ describe('bodyParser.urlencoded()', function () {
request(createServer({
parser: function (input) { return input.toUpperCase() }
}))
.post('/')
.set('Content-Type', 'application/x-www-form-urlencoded')
.send('user=tobi')
.expect(200, '"USER=TOBI"', done)
.post('/')
.set('Content-Type', 'application/x-www-form-urlencoded')
.send('user=tobi')
.expect(200, '"USER=TOBI"', done)
})

it('should 400 when invalid content-length', function (done) {
Expand Down