app.router.js
This file
Path
test/app.router.js
1,217 lines · 29.1 KiB · JavaScript
Last changed by
docs: fix pass-through typos (#7509)whoalin1before adoption9efc29e
History of this fileTake it
The walk stopped after 200 commits: lines older than 2027b87 point at it.
fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1–5why, one step back1'use strict'23var after = require('after');4var express = require('../')5 , request = require('supertest')fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 6why, one step back6 , assert = require('node:assert')chore: replace `methods` dependency with standard library (#6196)Jon Koopsbefore adoptionb11122b
line 7why, one step back7 , methods = require('../lib/utils').methods;fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 8–10why, one step back89var shouldSkipQuery = require('./support/utils').shouldSkipQuery10fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 11–12why, one step back11describe('app.router', function () {12 it('should restore req.params after leaving router', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 13–15why, one step back13 var app = express();14 var router = new express.Router();15fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 16why, one step back16 function handler1(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 17–20why, one step back17 res.setHeader('x-user-id', String(req.params.id));18 next()19 }20fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 21why, one step back21 function handler2(req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 22–24why, one step back22 res.send(req.params.id);23 }24fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 25why, one step back25 router.use(function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 26–32why, one step back26 res.setHeader('x-router', String(req.params.id));27 next();28 });2930 app.get('/user/:id', handler1, router, handler2);3132 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 33–36why, one step back33 .get('/user/1')34 .expect('x-router', 'undefined')35 .expect('x-user-id', '1')36 .expect(200, '1', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 37–38why, one step back37 })38fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 39–40why, one step back39 describe('methods', function () {40 methods.forEach(function (method) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 41–42why, one step back41 if (method === 'connect') return;42fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 43why, one step back43 it('should include ' + method.toUpperCase(), function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 44–48why, one step back44 if (method === 'query' && shouldSkipQuery(process.versions.node)) {45 this.skip()46 }47 var app = express();48fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 49why, one step back49 app[method]('/foo', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 50–54why, one step back50 res.send(method)51 });5253 request(app)54 [method]('/foo')fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 55why, one step back55 .expect(200, done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 56–57why, one step back56 })57fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 58why, one step back58 it('should reject numbers for app.' + method, function () {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 59–79why, one step back59 var app = express();60 assert.throws(app[method].bind(app, '/', 3), /argument handler must be a function/);61 })62 });6364 it('should re-route when method is altered', function (done) {65 var app = express();66 var cb = after(3, done);6768 app.use(function (req, res, next) {69 if (req.method !== 'POST') return next();70 req.method = 'DELETE';71 res.setHeader('X-Method-Altered', '1');72 next();73 });7475 app.delete('/', function (req, res) {76 res.end('deleted everything');77 });7879 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 80–81why, one step back80 .get('/')81 .expect(404, cb)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 82–83why, one step back8283 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 84–85why, one step back84 .delete('/')85 .expect(200, 'deleted everything', cb);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 86–87why, one step back8687 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 88–90why, one step back88 .post('/')89 .expect('X-Method-Altered', '1')90 .expect(200, 'deleted everything', cb);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 91–94why, one step back91 });92 })9394 describe('decode params', function () {fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 95why, one step back95 it('should decode correct params', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 96–102why, one step back96 var app = express();9798 app.get('/:name', function (req, res) {99 res.send(req.params.name);100 });101102 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 103–104why, one step back103 .get('/foo%2Fbar')104 .expect('foo/bar', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 105–106why, one step back105 })106fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 107why, one step back107 it('should not accept params in malformed paths', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 108–114why, one step back108 var app = express();109110 app.get('/:name', function (req, res) {111 res.send(req.params.name);112 });113114 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 115–116why, one step back115 .get('/%foobar')116 .expect(400, done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 117–118why, one step back117 })118fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 119why, one step back119 it('should not decode spaces', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 120–126why, one step back120 var app = express();121122 app.get('/:name', function (req, res) {123 res.send(req.params.name);124 });125126 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 127–128why, one step back127 .get('/foo+bar')128 .expect('foo+bar', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 129–130why, one step back129 })130fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 131why, one step back131 it('should work with unicode', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 132–138why, one step back132 var app = express();133134 app.get('/:name', function (req, res) {135 res.send(req.params.name);136 });137138 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 139–140why, one step back139 .get('/%ce%b1')140 .expect('\u03b1', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 141–143why, one step back141 })142 })143fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 144why, one step back144 it('should be .use()able', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 145–148why, one step back145 var app = express();146147 var calls = [];148fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 149why, one step back149 app.use(function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 150–153why, one step back150 calls.push('before');151 next();152 });153fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 154why, one step back154 app.get('/', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 155–158why, one step back155 calls.push('GET /')156 next();157 });158fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 159why, one step back159 app.use(function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 160–164why, one step back160 calls.push('after');161 res.json(calls)162 });163164 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 165–166why, one step back165 .get('/')166 .expect(200, ['before', 'GET /', 'after'], done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 167–168why, one step back167 })168fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 169–170why, one step back169 describe('when given a regexp', function () {170 it('should match the pathname only', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 171–172why, one step back171 var app = express();172fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 173why, one step back173 app.get(/^\/user\/[0-9]+$/, function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 174–177why, one step back174 res.end('user');175 });176177 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 178–179why, one step back178 .get('/user/12?foo=bar')179 .expect('user', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 180–181why, one step back180 })181fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 182why, one step back182 it('should populate req.params with the captures', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 183–184why, one step back183 var app = express();184fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 185why, one step back185 app.get(/^\/user\/([0-9]+)\/(view|edit)?$/, function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 186–191why, one step back186 var id = req.params[0]187 , op = req.params[1];188 res.end(op + 'ing user ' + id);189 });190191 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 192–193why, one step back192 .get('/user/10/edit')193 .expect('editing user 10', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 194–196why, one step back194 })195196 if (supportsRegexp('(?<foo>.*)')) {fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 197why, one step back197 it('should populate req.params with named captures', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 198–200why, one step back198 var app = express();199 var re = new RegExp('^/user/(?<userId>[0-9]+)/(view|edit)?$');200fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 201why, one step back201 app.get(re, function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 202–207why, one step back202 var id = req.params.userId203 , op = req.params[0];204 res.end(op + 'ing user ' + id);205 });206207 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 208–209why, one step back208 .get('/user/10/edit')209 .expect('editing user 10', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 210–242why, one step back210 })211 }212213 it('should ensure regexp matches path prefix', function (done) {214 var app = express()215 var p = []216217 app.use(/\/api.*/, function (req, res, next) {218 p.push('a')219 next()220 })221 app.use(/api/, function (req, res, next) {222 p.push('b')223 next()224 })225 app.use(/\/test/, function (req, res, next) {226 p.push('c')227 next()228 })229 app.use(function (req, res) {230 res.end()231 })232233 request(app)234 .get('/test/api/1234')235 .expect(200, function (err) {236 if (err) return done(err)237 assert.deepEqual(p, ['c'])238 done()239 })240 })241 })242fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 243–244why, one step back243 describe('case sensitivity', function () {244 it('should be disabled by default', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 245–246why, one step back245 var app = express();246fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 247why, one step back247 app.get('/user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 248–251why, one step back248 res.end('tj');249 });250251 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 252–253why, one step back252 .get('/USER')253 .expect('tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 254–255why, one step back254 })255fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 256–257why, one step back256 describe('when "case sensitive routing" is enabled', function () {257 it('should match identical casing', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 258–261why, one step back258 var app = express();259260 app.enable('case sensitive routing');261fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 262why, one step back262 app.get('/uSer', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 263–266why, one step back263 res.end('tj');264 });265266 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 267–268why, one step back267 .get('/uSer')268 .expect('tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 269–270why, one step back269 })270fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 271why, one step back271 it('should not match otherwise', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 272–275why, one step back272 var app = express();273274 app.enable('case sensitive routing');275fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 276why, one step back276 app.get('/uSer', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 277–280why, one step back277 res.end('tj');278 });279280 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 281–282why, one step back281 .get('/user')282 .expect(404, done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 283–286why, one step back283 })284 })285 })286fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 287–288why, one step back287 describe('params', function () {288 it('should overwrite existing req.params by default', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 289–291why, one step back289 var app = express();290 var router = new express.Router();291fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 292why, one step back292 router.get('/:action', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 293–298why, one step back293 res.send(req.params);294 });295296 app.use('/user/:user', router);297298 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 299–300why, one step back299 .get('/user/1/get')300 .expect(200, '{"action":"get"}', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 301–302why, one step back301 })302fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 303why, one step back303 it('should allow merging existing req.params', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 304–306why, one step back304 var app = express();305 var router = new express.Router({ mergeParams: true });306fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 307why, one step back307 router.get('/:action', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
line 308why, one step back308 var keys = Object.keys(req.params).sort();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 309why, one step back309 res.send(keys.map(function (k) { return [k, req.params[k]] }));fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 310–314why, one step back310 });311312 app.use('/user/:user', router);313314 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 315–316why, one step back315 .get('/user/tj/get')316 .expect(200, '[["action","get"],["user","tj"]]', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 317–318why, one step back317 })318fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 319why, one step back319 it('should use params from router', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 320–322why, one step back320 var app = express();321 var router = new express.Router({ mergeParams: true });322fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 323why, one step back323 router.get('/:thing', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
line 324why, one step back324 var keys = Object.keys(req.params).sort();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 325why, one step back325 res.send(keys.map(function (k) { return [k, req.params[k]] }));fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 326–330why, one step back326 });327328 app.use('/user/:thing', router);329330 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 331–332why, one step back331 .get('/user/tj/get')332 .expect(200, '[["thing","get"]]', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 333–334why, one step back333 })334fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 335why, one step back335 it('should merge numeric indices req.params', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 336–340why, one step back336 var app = express();337 var router = new express.Router({ mergeParams: true });338339 router.get(/^\/(.*)\.(.*)/, function (req, res) {340 var keys = Object.keys(req.params).sort();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 341why, one step back341 res.send(keys.map(function (k) { return [k, req.params[k]] }));fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 342–346why, one step back342 });343344 app.use(/^\/user\/id:(\d+)/, router);345346 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 347–348why, one step back347 .get('/user/id:10/profile.json')348 .expect(200, '[["0","10"],["1","profile"],["2","json"]]', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 349–350why, one step back349 })350fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 351why, one step back351 it('should merge numeric indices req.params when more in parent', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 352–356why, one step back352 var app = express();353 var router = new express.Router({ mergeParams: true });354355 router.get(/\/(.*)/, function (req, res) {356 var keys = Object.keys(req.params).sort();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 357why, one step back357 res.send(keys.map(function (k) { return [k, req.params[k]] }));fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 358–362why, one step back358 });359360 app.use(/^\/user\/id:(\d+)\/name:(\w+)/, router);361362 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 363–364why, one step back363 .get('/user/id:10/name:tj/profile')364 .expect(200, '[["0","10"],["1","tj"],["2","profile"]]', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 365–366why, one step back365 })366fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 367why, one step back367 it('should merge numeric indices req.params when parent has same number', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 368–370why, one step back368 var app = express();369 var router = new express.Router({ mergeParams: true });370fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 371why, one step back371 router.get(/\/name:(\w+)/, function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
line 372why, one step back372 var keys = Object.keys(req.params).sort();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 373why, one step back373 res.send(keys.map(function (k) { return [k, req.params[k]] }));fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 374–378why, one step back374 });375376 app.use(/\/user\/id:(\d+)/, router);377378 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 379–380why, one step back379 .get('/user/id:10/name:tj')380 .expect(200, '[["0","10"],["1","tj"]]', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 381–382why, one step back381 })382fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 383why, one step back383 it('should ignore invalid incoming req.params', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 384–386why, one step back384 var app = express();385 var router = new express.Router({ mergeParams: true });386fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 387why, one step back387 router.get('/:name', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
line 388why, one step back388 var keys = Object.keys(req.params).sort();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 389why, one step back389 res.send(keys.map(function (k) { return [k, req.params[k]] }));fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 390–397why, one step back390 });391392 app.use('/user/', function (req, res, next) {393 req.params = 3; // wat?394 router(req, res, next);395 });396397 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 398–399why, one step back398 .get('/user/tj')399 .expect(200, '[["name","tj"]]', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 400–401why, one step back400 })401fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 402why, one step back402 it('should restore req.params', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 403–412why, one step back403 var app = express();404 var router = new express.Router({ mergeParams: true });405406 router.get(/\/user:(\w+)\//, function (req, res, next) {407 next();408 });409410 app.use(/\/user\/id:(\d+)/, function (req, res, next) {411 router(req, res, function (err) {412 var keys = Object.keys(req.params).sort();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 413why, one step back413 res.send(keys.map(function (k) { return [k, req.params[k]] }));fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 414–417why, one step back414 });415 });416417 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 418–419why, one step back418 .get('/user/id:42/user:tj/profile')419 .expect(200, '[["0","42"]]', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 420–422why, one step back420 })421 })422fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 423–424why, one step back423 describe('trailing slashes', function () {424 it('should be optional by default', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 425–426why, one step back425 var app = express();426fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 427why, one step back427 app.get('/user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 428–431why, one step back428 res.end('tj');429 });430431 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 432–433why, one step back432 .get('/user/')433 .expect('tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 434–435why, one step back434 })435fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 436–437why, one step back436 describe('when "strict routing" is enabled', function () {437 it('should match trailing slashes', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 438–441why, one step back438 var app = express();439440 app.enable('strict routing');441fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 442why, one step back442 app.get('/user/', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 443–446why, one step back443 res.end('tj');444 });445446 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 447–448why, one step back447 .get('/user/')448 .expect('tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 449–450why, one step back449 })450docs: fix pass-through typos (#7509)whoalin1before adoption9efc29e
line 451why, one step back451 it('should pass-through middleware', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 452–460why, one step back452 var app = express();453454 app.enable('strict routing');455456 app.use(function (req, res, next) {457 res.setHeader('x-middleware', 'true');458 next();459 });460fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 461why, one step back461 app.get('/user/', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 462–465why, one step back462 res.end('tj');463 });464465 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 466–468why, one step back466 .get('/user/')467 .expect('x-middleware', 'true')468 .expect(200, 'tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 469–470why, one step back469 })470docs: fix pass-through typos (#7509)whoalin1before adoption9efc29e
line 471why, one step back471 it('should pass-through mounted middleware', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 472–480why, one step back472 var app = express();473474 app.enable('strict routing');475476 app.use('/user/', function (req, res, next) {477 res.setHeader('x-middleware', 'true');478 next();479 });480fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 481why, one step back481 app.get('/user/test/', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 482–485why, one step back482 res.end('tj');483 });484485 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 486–488why, one step back486 .get('/user/test/')487 .expect('x-middleware', 'true')488 .expect(200, 'tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 489–490why, one step back489 })490fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 491why, one step back491 it('should match no slashes', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 492–495why, one step back492 var app = express();493494 app.enable('strict routing');495fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 496why, one step back496 app.get('/user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 497–500why, one step back497 res.end('tj');498 });499500 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 501–502why, one step back501 .get('/user')502 .expect('tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 503–504why, one step back503 })504fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 505why, one step back505 it('should match middleware when omitting the trailing slash', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 506–509why, one step back506 var app = express();507508 app.enable('strict routing');509fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 510why, one step back510 app.use('/user/', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 511–514why, one step back511 res.end('tj');512 });513514 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 515–516why, one step back515 .get('/user')516 .expect(200, 'tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 517–518why, one step back517 })518fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 519why, one step back519 it('should match middleware', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 520–523why, one step back520 var app = express();521522 app.enable('strict routing');523fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 524why, one step back524 app.use('/user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 525–528why, one step back525 res.end('tj');526 });527528 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 529–530why, one step back529 .get('/user')530 .expect(200, 'tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 531–532why, one step back531 })532fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 533why, one step back533 it('should match middleware when adding the trailing slash', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 534–537why, one step back534 var app = express();535536 app.enable('strict routing');537fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 538why, one step back538 app.use('/user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 539–542why, one step back539 res.end('tj');540 });541542 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 543–544why, one step back543 .get('/user/')544 .expect(200, 'tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 545–546why, one step back545 })546fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 547why, one step back547 it('should fail when omitting the trailing slash', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 548–551why, one step back548 var app = express();549550 app.enable('strict routing');551fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 552why, one step back552 app.get('/user/', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 553–556why, one step back553 res.end('tj');554 });555556 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 557–558why, one step back557 .get('/user')558 .expect(404, done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 559–560why, one step back559 })560fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 561why, one step back561 it('should fail when adding the trailing slash', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 562–565why, one step back562 var app = express();563564 app.enable('strict routing');565fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 566why, one step back566 app.get('/user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 567–570why, one step back567 res.end('tj');568 });569570 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 571–572why, one step back571 .get('/user/')572 .expect(404, done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 573–576why, one step back573 })574 })575 })576fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 577why, one step back577 it('should allow literal "."', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 578–579why, one step back578 var app = express();579fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 580why, one step back580 app.get('/api/users/:from..:to', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 581–587why, one step back581 var from = req.params.from582 , to = req.params.to;583584 res.end('users from ' + from + ' to ' + to);585 });586587 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 588–589why, one step back588 .get('/api/users/1..50')589 .expect('users from 1 to 50', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 590–591why, one step back590 })591fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 592–593why, one step back592 describe(':name', function () {593 it('should denote a capture group', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 594–595why, one step back594 var app = express();595fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 596why, one step back596 app.get('/user/:user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 597–600why, one step back597 res.end(req.params.user);598 });599600 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 601–602why, one step back601 .get('/user/tj')602 .expect('tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 603–604why, one step back603 })604fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 605why, one step back605 it('should match a single segment only', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 606–607why, one step back606 var app = express();607fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 608why, one step back608 app.get('/user/:user', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 609–612why, one step back609 res.end(req.params.user);610 });611612 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 613–614why, one step back613 .get('/user/tj/edit')614 .expect(404, done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 615–616why, one step back615 })616fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 617why, one step back617 it('should allow several capture groups', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 618–619why, one step back618 var app = express();619fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 620why, one step back620 app.get('/user/:user/:op', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 621–624why, one step back621 res.end(req.params.op + 'ing ' + req.params.user);622 });623624 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 625–626why, one step back625 .get('/user/tj/edit')626 .expect('editing tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 627–628why, one step back627 })628fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 629why, one step back629 it('should work following a partial capture group', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 630–632why, one step back630 var app = express();631 var cb = after(2, done);632fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 633why, one step back633 app.get('/user{s}/:user/:op', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 634–637why, one step back634 res.end(req.params.op + 'ing ' + req.params.user + (req.url.startsWith('/users') ? ' (old)' : ''));635 });636637 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 638–639why, one step back638 .get('/user/tj/edit')639 .expect('editing tj', cb);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 640–641why, one step back640641 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 642–643why, one step back642 .get('/users/tj/edit')643 .expect('editing tj (old)', cb);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 644–645why, one step back644 })645fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 646why, one step back646 it('should work inside literal parenthesis', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 647–648why, one step back647 var app = express();648fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 649why, one step back649 app.get('/:user\\(:op\\)', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 650–653why, one step back650 res.end(req.params.op + 'ing ' + req.params.user);651 });652653 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 654–655why, one step back654 .get('/tj(edit)')655 .expect('editing tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 656–657why, one step back656 })657fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 658why, one step back658 it('should work in array of paths', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 659–661why, one step back659 var app = express();660 var cb = after(2, done);661fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 662why, one step back662 app.get(['/user/:user/poke', '/user/:user/pokes'], function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 663–666why, one step back663 res.end('poking ' + req.params.user);664 });665666 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 667–668why, one step back667 .get('/user/tj/poke')668 .expect('poking tj', cb);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 669–670why, one step back669670 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 671–672why, one step back671 .get('/user/tj/pokes')672 .expect('poking tj', cb);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 673–675why, one step back673 })674 })675fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 676–677why, one step back676 describe(':name?', function () {677 it('should denote an optional capture group', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 678–679why, one step back678 var app = express();679fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 680why, one step back680 app.get('/user/:user{/:op}', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 681–685why, one step back681 var op = req.params.op || 'view';682 res.end(op + 'ing ' + req.params.user);683 });684685 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 686–687why, one step back686 .get('/user/tj')687 .expect('viewing tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 688–689why, one step back688 })689fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 690why, one step back690 it('should populate the capture group', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 691–692why, one step back691 var app = express();692fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 693why, one step back693 app.get('/user/:user{/:op}', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 694–698why, one step back694 var op = req.params.op || 'view';695 res.end(op + 'ing ' + req.params.user);696 });697698 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 699–700why, one step back699 .get('/user/tj/edit')700 .expect('editing tj', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 701–779why, one step back701 })702 })703704 describe(':name*', function () {705 it('should match one segment', function (done) {706 var app = express()707708 app.get('/user/*user', function (req, res) {709 res.end(req.params.user[0])710 })711712 request(app)713 .get('/user/122')714 .expect('122', done)715 })716717 it('should match many segments', function (done) {718 var app = express()719720 app.get('/user/*user', function (req, res) {721 res.end(req.params.user.join('/'))722 })723724 request(app)725 .get('/user/1/2/3/4')726 .expect('1/2/3/4', done)727 })728729 it('should match zero segments', function (done) {730 var app = express()731732 app.get('/user{/*user}', function (req, res) {733 res.end(req.params.user)734 })735736 request(app)737 .get('/user')738 .expect('', done)739 })740 })741742 describe(':name+', function () {743 it('should match one segment', function (done) {744 var app = express()745746 app.get('/user/*user', function (req, res) {747 res.end(req.params.user[0])748 })749750 request(app)751 .get('/user/122')752 .expect(200, '122', done)753 })754755 it('should match many segments', function (done) {756 var app = express()757758 app.get('/user/*user', function (req, res) {759 res.end(req.params.user.join('/'))760 })761762 request(app)763 .get('/user/1/2/3/4')764 .expect(200, '1/2/3/4', done)765 })766767 it('should not match zero segments', function (done) {768 var app = express()769770 app.get('/user/*user', function (req, res) {771 res.end(req.params.user)772 })773774 request(app)775 .get('/user')776 .expect(404, done)777 })778 })779fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 780–781why, one step back780 describe('.:name', function () {781 it('should denote a format', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 782–784why, one step back782 var app = express();783 var cb = after(2, done)784fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 785why, one step back785 app.get('/:name.:format', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 786–798why, one step back786 res.end(req.params.name + ' as ' + req.params.format);787 });788789 request(app)790 .get('/foo.json')791 .expect(200, 'foo as json', cb)792793 request(app)794 .get('/foo')795 .expect(404, cb)796 })797 })798fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 799–800why, one step back799 describe('.:name?', function () {800 it('should denote an optional format', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 801–803why, one step back801 var app = express();802 var cb = after(2, done)803fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 804why, one step back804 app.get('/:name{.:format}', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 805–817why, one step back805 res.end(req.params.name + ' as ' + (req.params.format || 'html'));806 });807808 request(app)809 .get('/foo')810 .expect(200, 'foo as html', cb)811812 request(app)813 .get('/foo.json')814 .expect(200, 'foo as json', cb)815 })816 })817fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 818–819why, one step back818 describe('when next() is called', function () {819 it('should continue lookup', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 820–822why, one step back820 var app = express()821 , calls = [];822fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 823why, one step back823 app.get('/foo{/:bar}', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 824–831why, one step back824 calls.push('/foo/:bar?');825 next();826 });827828 app.get('/bar', function () {829 assert(0);830 });831fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 832why, one step back832 app.get('/foo', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 833–842why, one step back833 calls.push('/foo');834 next();835 });836837 app.get('/foo', function (req, res) {838 calls.push('/foo 2');839 res.json(calls)840 });841842 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 843–844why, one step back843 .get('/foo')844 .expect(200, ['/foo/:bar?', '/foo', '/foo 2'], done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 845–847why, one step back845 })846 })847fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 848–849why, one step back848 describe('when next("route") is called', function () {849 it('should jump to next route', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 850–851why, one step back850 var app = express()851fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 852why, one step back852 function fn(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 853–860why, one step back853 res.set('X-Hit', '1')854 next('route')855 }856857 app.get('/foo', fn, function (req, res) {858 res.end('failure')859 });860fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 861why, one step back861 app.get('/foo', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 862–865why, one step back862 res.end('success')863 })864865 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 866–868why, one step back866 .get('/foo')867 .expect('X-Hit', '1')868 .expect(200, 'success', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 869–876why, one step back869 })870 })871872 describe('when next("router") is called', function () {873 it('should jump out of router', function (done) {874 var app = express()875 var router = express.Router()876fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 877why, one step back877 function fn(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 878–896why, one step back878 res.set('X-Hit', '1')879 next('router')880 }881882 router.get('/foo', fn, function (req, res) {883 res.end('failure')884 })885886 router.get('/foo', function (req, res) {887 res.end('failure')888 })889890 app.use(router)891892 app.get('/foo', function (req, res) {893 res.end('success')894 })895896 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 897–899why, one step back897 .get('/foo')898 .expect('X-Hit', '1')899 .expect(200, 'success', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 900–902why, one step back900 })901 })902fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 903–904why, one step back903 describe('when next(err) is called', function () {904 it('should break out of app.router', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 905–907why, one step back905 var app = express()906 , calls = [];907fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 908why, one step back908 app.get('/foo{/:bar}', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 909–916why, one step back909 calls.push('/foo/:bar?');910 next();911 });912913 app.get('/bar', function () {914 assert(0);915 });916fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 917why, one step back917 app.get('/foo', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 918–925why, one step back918 calls.push('/foo');919 next(new Error('fail'));920 });921922 app.get('/foo', function () {923 assert(0);924 });925fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 926why, one step back926 app.use(function (err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 927–933why, one step back927 res.json({928 calls: calls,929 error: err.message930 })931 })932933 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 934–935why, one step back934 .get('/foo')935 .expect(200, { calls: ['/foo/:bar?', '/foo'], error: 'fail' }, done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 936–937why, one step back936 })937fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 938why, one step back938 it('should call handler in same route, if exists', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 939–959why, one step back939 var app = express();940941 function fn1(req, res, next) {942 next(new Error('boom!'));943 }944945 function fn2(req, res, next) {946 res.send('foo here');947 }948949 function fn3(err, req, res, next) {950 res.send('route go ' + err.message);951 }952953 app.get('/foo', fn1, fn2, fn3);954955 app.use(function (err, req, res, next) {956 res.end('error!');957 })958959 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 960–961why, one step back960 .get('/foo')961 .expect('route go boom!', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 962–964why, one step back962 })963 })964chore(test): remove promise support check from tests (#6148)Phillip Bartabefore adoption9e3dbb4
line 965why, one step back965 describe('promise support', function () {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 966–969why, one step back966 it('should pass rejected promise value', function (done) {967 var app = express()968 var router = new express.Router()969fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 970why, one step back970 router.use(function createError(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 971–973why, one step back971 return Promise.reject(new Error('boom!'))972 })973fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 974why, one step back974 router.use(function sawError(err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 975–980why, one step back975 res.send('saw ' + err.name + ': ' + err.message)976 })977978 app.use(router)979980 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 981–982why, one step back981 .get('/')982 .expect(200, 'saw Error: boom!', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 983–988why, one step back983 })984985 it('should pass rejected promise without value', function (done) {986 var app = express()987 var router = new express.Router()988fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 989why, one step back989 router.use(function createError(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 990–992why, one step back990 return Promise.reject()991 })992fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 993why, one step back993 router.use(function sawError(err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 994–999why, one step back994 res.send('saw ' + err.name + ': ' + err.message)995 })996997 app.use(router)998999 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1000–1001why, one step back1000 .get('/')1001 .expect(200, 'saw Error: Rejected promise', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1002–1007why, one step back1002 })10031004 it('should ignore resolved promise', function (done) {1005 var app = express()1006 var router = new express.Router()1007fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1008why, one step back1008 router.use(function createError(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1009–1019why, one step back1009 res.send('saw GET /foo')1010 return Promise.resolve('foo')1011 })10121013 router.use(function () {1014 done(new Error('Unexpected middleware invoke'))1015 })10161017 app.use(router)10181019 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1020–1021why, one step back1020 .get('/foo')1021 .expect(200, 'saw GET /foo', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1022–1028why, one step back1022 })10231024 describe('error handling', function () {1025 it('should pass rejected promise value', function (done) {1026 var app = express()1027 var router = new express.Router()1028fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1029why, one step back1029 router.use(function createError(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1030–1032why, one step back1030 return Promise.reject(new Error('boom!'))1031 })1032fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1033why, one step back1033 router.use(function handleError(err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1034–1036why, one step back1034 return Promise.reject(new Error('caught: ' + err.message))1035 })1036fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1037why, one step back1037 router.use(function sawError(err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1038–1043why, one step back1038 res.send('saw ' + err.name + ': ' + err.message)1039 })10401041 app.use(router)10421043 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1044–1045why, one step back1044 .get('/')1045 .expect(200, 'saw Error: caught: boom!', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1046–1051why, one step back1046 })10471048 it('should pass rejected promise without value', function (done) {1049 var app = express()1050 var router = new express.Router()1051fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1052why, one step back1052 router.use(function createError(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1053–1055why, one step back1053 return Promise.reject()1054 })1055fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1056why, one step back1056 router.use(function handleError(err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1057–1059why, one step back1057 return Promise.reject(new Error('caught: ' + err.message))1058 })1059fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1060why, one step back1060 router.use(function sawError(err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1061–1066why, one step back1061 res.send('saw ' + err.name + ': ' + err.message)1062 })10631064 app.use(router)10651066 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1067–1068why, one step back1067 .get('/')1068 .expect(200, 'saw Error: caught: Rejected promise', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1069–1074why, one step back1069 })10701071 it('should ignore resolved promise', function (done) {1072 var app = express()1073 var router = new express.Router()1074fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1075why, one step back1075 router.use(function createError(req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1076–1078why, one step back1076 return Promise.reject(new Error('boom!'))1077 })1078fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1079why, one step back1079 router.use(function handleError(err, req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1080–1090why, one step back1080 res.send('saw ' + err.name + ': ' + err.message)1081 return Promise.resolve('foo')1082 })10831084 router.use(function () {1085 done(new Error('Unexpected middleware invoke'))1086 })10871088 app.use(router)10891090 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1091–1092why, one step back1091 .get('/foo')1092 .expect(200, 'saw Error: boom!', done)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1093–1096why, one step back1093 })1094 })1095 })1096fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1097why, one step back1097 it('should allow rewriting of the url', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1098–1099why, one step back1098 var app = express();1099fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1100why, one step back1100 app.get('/account/edit', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1101–1105why, one step back1101 req.user = { id: 12 }; // faux authenticated user1102 req.url = '/user/' + req.user.id + '/edit';1103 next();1104 });1105fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1106why, one step back1106 app.get('/user/:id/edit', function (req, res) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1107–1110why, one step back1107 res.send('editing user ' + req.params.id);1108 });11091110 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1111–1112why, one step back1111 .get('/account/edit')1112 .expect('editing user 12', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1113–1114why, one step back1113 })1114fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1115why, one step back1115 it('should run in order added', function (done) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1116–1123why, one step back1116 var app = express();1117 var path = [];11181119 app.get('/*path', function (req, res, next) {1120 path.push(0);1121 next();1122 });1123fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1124why, one step back1124 app.get('/user/:id', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1125–1128why, one step back1125 path.push(1);1126 next();1127 });1128fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1129why, one step back1129 app.use(function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1130–1133why, one step back1130 path.push(2);1131 next();1132 });1133fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1134why, one step back1134 app.all('/user/:id', function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1135–1143why, one step back1135 path.push(3);1136 next();1137 });11381139 app.get('/*splat', function (req, res, next) {1140 path.push(4);1141 next();1142 });1143fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1144why, one step back1144 app.use(function (req, res, next) {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1145–1149why, one step back1145 path.push(5);1146 res.end(path.join(','))1147 });11481149 request(app)fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1150–1151why, one step back1150 .get('/user/1')1151 .expect(200, '0,1,2,3,4,5', done);fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1152–1153why, one step back1152 })1153fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1154why, one step back1154 it('should be chainable', function () {fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
line 1155why, one step back1155 var app = express();fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1156why, one step back1156 assert.strictEqual(app.get('/', function () { }), app)fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
line 1157why, one step back1157 })test: add discarded middleware test (#5819)Chris de Almeidabefore adoption082d6d1
line 1158why, one step back1158fix(test): remove duplicate word (#6456)dufucunbefore adoptionf9954dd
line 1159why, one step back1159 it('should not use disposed router/middleware', function (done) {test: add discarded middleware test (#5819)Chris de Almeidabefore adoption082d6d1
lines 1160–1164why, one step back1160 // more context: https://github.com/expressjs/express/issues/5743#issuecomment-227714841211611162 var app = express();1163 var router = new express.Router();1164fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1165why, one step back1165 router.use(function (req, res, next) {test: add discarded middleware test (#5819)Chris de Almeidabefore adoption082d6d1
lines 1166–1173why, one step back1166 res.setHeader('old', 'foo');1167 next();1168 });11691170 app.use(function (req, res, next) {1171 return router.handle(req, res, next);1172 });1173fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 1174why, one step back1174 app.get('/', function (req, res, next) {test: add discarded middleware test (#5819)Chris de Almeidabefore adoption082d6d1
lines 1175–1180why, one step back1175 res.send('yee');1176 next();1177 });11781179 request(app)1180 .get('/')fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1181–1184why, one step back1181 .expect('old', 'foo')1182 .expect(function (res) {1183 if (typeof res.headers['new'] !== 'undefined') {1184 throw new Error('`new` header should not be present');test: add discarded middleware test (#5819)Chris de Almeidabefore adoption082d6d1
lines 1185–1186why, one step back1185 }1186 })fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
lines 1187–1206why, one step back1187 .expect(200, 'yee', function (err, res) {1188 if (err) return done(err);11891190 router = new express.Router();11911192 router.use(function (req, res, next) {1193 res.setHeader('new', 'bar');1194 next();1195 });11961197 request(app)1198 .get('/')1199 .expect('new', 'bar')1200 .expect(function (res) {1201 if (typeof res.headers['old'] !== 'undefined') {1202 throw new Error('`old` header should not be present');1203 }1204 })1205 .expect(200, 'yee', done);1206 });test: add discarded middleware test (#5819)Chris de Almeidabefore adoption082d6d1
line 1207why, one step back1207 })fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1208–1217why, one step back1208})12091210function supportsRegexp(source) {1211 try {1212 new RegExp(source)1213 return true1214 } catch (e) {1215 return false1216 }1217}