prev.params should always exist (#227)
This commit is contained in:
@@ -119,7 +119,7 @@ function choo (opts) {
|
|||||||
// create a new router with a custom `createRoute()` function
|
// create a new router with a custom `createRoute()` function
|
||||||
// (str?, obj, fn?) -> null
|
// (str?, obj, fn?) -> null
|
||||||
function createRouter (defaultRoute, routes, createSend) {
|
function createRouter (defaultRoute, routes, createSend) {
|
||||||
var prev = {}
|
var prev = { params: {} }
|
||||||
return sheetRouter(defaultRoute, routes, createRoute)
|
return sheetRouter(defaultRoute, routes, createRoute)
|
||||||
|
|
||||||
function createRoute (routeFn) {
|
function createRoute (routeFn) {
|
||||||
|
|||||||
@@ -163,4 +163,21 @@ test('routing', function (t) {
|
|||||||
|
|
||||||
app.start()
|
app.start()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.test('prev.params always exists', function (t) {
|
||||||
|
t.plan(1)
|
||||||
|
|
||||||
|
const choo = require('../..')
|
||||||
|
const app = choo()
|
||||||
|
|
||||||
|
app.router('/users/123', (route) => [
|
||||||
|
route('/users', [
|
||||||
|
route('/:user', function (state, prev) {
|
||||||
|
t.ok(prev.params)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
app.start()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user