deps: body-parser@2.0.0-beta.1
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 1574925 · Browse files · 8 files·+23 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+23 added−14 removed
- tests:+10 added−10 removed
- other:+13 added−4 removed
Provenance
- Commit
af341b0- Tree
0c6765a- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
1574925
8 files changed+23 added−14 removed
modified:examples/auth/index.js+2 added-1 removed
14 unmodified lines1516171819192021222375 unmodified lines9910010110210310410510610724 unmodified lines14 unmodified linesapp.set('views', path.join(__dirname, 'views'));
// middleware
app.use(express.urlencoded({ extended: false }))app.use(express.urlencoded())app.use(session({ resave: false, // don't save session if unmodified saveUninitialized: false, // don't create session until something stored secret: 'shhhh, very secret'75 unmodified lines res.render('login');});
app.post('/login', function(req, res){ if (!req.body) return res.sendStatus(400) authenticate(req.body.username, req.body.password, function(err, user){ if (user) { // Regenerate session when signing in // to prevent fixation24 unmodified linesmodified:examples/cookies/index.js+6 added-2 removed
15 unmodified lines1617181920202122232410 unmodified lines35363738393940414243444546474 unmodified lines15 unmodified lines// for signing the cookies.app.use(cookieParser('my secret here'));
// parses x-www-form-urlencodedapp.use(express.urlencoded({ extended: false }))app.use(express.urlencoded())
app.get('/', function(req, res){ if (req.cookies.remember) { res.send('Remembered :). Click to <a href="/forget">forget</a>!.');10 unmodified lines});
app.post('/', function(req, res){ var minute = 60000; if (req.body.remember) res.cookie('remember', 1, { maxAge: minute });
if (req.body && req.body.remember) { res.cookie('remember', 1, { maxAge: minute }) }
res.redirect('back');});
/* istanbul ignore next */4 unmodified linesmodified:test/express.json.js+2 added-2 removed
310 unmodified lines311 request(this.app)312 .post('/')313 .set('Content-Type', 'application/json')314 .send('{"user":"tobi"}')315- .expect(200, '{}', done)315+ .expect(200, '', done)316 })317 })318 319 describe('when ["application/json", "application/vnd.api+json"]', function () {23 unmodified lines343 request(this.app)344 .post('/')345 .set('Content-Type', 'application/x-json')346 .send('{"user":"tobi"}')347- .expect(200, '{}', done)347+ .expect(200, '', done)348 })349 })350 351 describe('when a function', function () {313 unmodified linesmodified:test/express.raw.js+2 added-2 removed
180 unmodified lines181 it('should ignore standard type', function (done) {182 var test = request(this.app).post('/')183 test.set('Content-Type', 'application/octet-stream')184 test.write(Buffer.from('000102', 'hex'))185- test.expect(200, '{}', done)185+ test.expect(200, '', done)186 })187 })188 189 describe('when ["application/octet-stream", "application/vnd+octets"]', function () {20 unmodified lines210 it('should ignore "application/x-foo"', function (done) {211 var test = request(this.app).post('/')212 test.set('Content-Type', 'application/x-foo')213 test.write(Buffer.from('000102', 'hex'))214- test.expect(200, '{}', done)214+ test.expect(200, '', done)215 })216 })217 218 describe('when a function', function () {169 unmodified linesmodified:test/express.text.js+2 added-2 removed
193 unmodified lines194 request(this.app)195 .post('/')196 .set('Content-Type', 'text/plain')197 .send('user is tobi')198- .expect(200, '{}', done)198+ .expect(200, '', done)199 })200 })201 202 describe('when ["text/html", "text/plain"]', function () {21 unmodified lines224 request(this.app)225 .post('/')226 .set('Content-Type', 'text/xml')227 .send('<user>tobi</user>')228- .expect(200, '{}', done)228+ .expect(200, '', done)229 })230 })231 232 describe('when a function', function () {209 unmodified linesmodified:test/express.urlencoded.js+4 added-4 removed
71 unmodified lines72 .send('user=tobi')73 .expect(200, '{"user":"tobi"}', done)74 })75 76- it('should parse extended syntax', function (done) {76+ it('should not parse extended syntax', function (done) {77 request(this.app)78 .post('/')79 .set('Content-Type', 'application/x-www-form-urlencoded')80 .send('user[name][first]=Tobi')81- .expect(200, '{"user":{"name":{"first":"Tobi"}}}', done)81+ .expect(200, '{"user[name][first]":"Tobi"}', done)82 })83 84 describe('with extended option', function () {85 describe('when false', function () {354 unmodified lines440 request(this.app)441 .post('/')442 .set('Content-Type', 'application/x-www-form-urlencoded')443 .send('user=tobi')444- .expect(200, '{}', done)444+ .expect(200, '', done)445 })446 })447 448 describe('when ["urlencoded", "application/x-pairs"]', function () {23 unmodified lines472 request(this.app)473 .post('/')474 .set('Content-Type', 'application/x-foo')475 .send('user=tobi')476- .expect(200, '{}', done)476+ .expect(200, '', done)477 })478 })479 480 describe('when a function', function () {254 unmodified linesmodified:History.md+4 added
1 unmodified line2 ===3 4 This incorporates all changes after 4.17.1 up to 4.17.2.5 6+ * deps: body-parser@2.0.0-beta.17+ - `req.body` is no longer always initialized to `{}`8+ - `urlencoded` parser now defaults `extended` to `false`9+ - Use `on-finished` to determine when body read10 * deps: router@2.0.0-beta.111 - Add new `?`, `*`, and `+` parameter modifiers12 - Internalize private `router.process_params` method13 - Matching group expressions are only RegExp syntax3640 unmodified linesmodified:package.json+1 added-1 removed
28 unmodified lines29 ],30 "dependencies": {31 "accepts": "~1.3.7",32 "array-flatten": "2.1.1",33- "body-parser": "1.19.1",33+ "body-parser": "2.0.0-beta.1",34 "content-disposition": "0.5.4",35 "content-type": "~1.0.4",36 "cookie": "0.4.1",37 "cookie-signature": "1.0.6",63 unmodified lines