-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
populate ctx.params
before running any matched middleware
#490
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -849,35 +849,6 @@ describe('Router', function () { | |
expect(router.stack[0]).to.have.property('path', '/one'); | ||
expect(router.stack[1]).to.have.property('path', '/two'); | ||
}); | ||
|
||
it('resolves non-parameterized routes without attached parameters', function(done) { | ||
var app = new Koa(); | ||
var router = new Router(); | ||
|
||
router.get('/notparameter', function (ctx, next) { | ||
ctx.body = { | ||
param: ctx.params.parameter, | ||
}; | ||
}); | ||
|
||
router.get('/:parameter', function (ctx, next) { | ||
ctx.body = { | ||
param: ctx.params.parameter, | ||
}; | ||
}); | ||
|
||
app.use(router.routes()); | ||
request(http.createServer(app.callback())) | ||
.get('/notparameter') | ||
.expect(200) | ||
.end(function (err, res) { | ||
if (err) return done(err); | ||
|
||
expect(res.body.param).to.equal(undefined); | ||
done(); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @smkoyan this test is important and removing it will not allow us to check use cases where users want a specific route to be hit followed by a catch-all route. router.get('/specific-route') // Hit when specific-route is provided
router.get('/:catchall') // Hit in any other case with a capture There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in #508 |
||
|
||
}); | ||
|
||
describe('Router#use()', function (done) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is needed in order to pass in
params
to theRouter.prototype.param
function in nested routers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in #508