koa-trie-router
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -9,4 +9,5 @@ var Router = require('./router') | ||
var node = match && match.node | ||
// If no match, go to next middleware | ||
if (notMatch(node)) return yield* next | ||
// If no route match or no methods are defined, go to next middleware | ||
// TODO: make node.methods more well-defined | ||
if (!node || !node.methods) return yield* next | ||
@@ -38,9 +39,2 @@ // If no HEAD middleware, default to GET. | ||
function notMatch(node) { | ||
if (!node) return true; | ||
if (Object.keys(node.child).length) return true; | ||
return false; | ||
} | ||
function* noop() {} |
@@ -42,10 +42,7 @@ | ||
if (!paths.length) throw new Error('Route must have a path') | ||
assert(paths.length, 'Route must have a path') | ||
paths.forEach(function (path) { | ||
if (typeof path !== 'string') | ||
throw new TypeError('Paths must be strings: ' + path) | ||
if (path !== '/' && path[0] !== '/') | ||
throw new Error('Paths must start with a "/": ' + path) | ||
assert(typeof path === 'string', 'Paths must be strings: ' + path) | ||
assert(path[0] === '/', 'Paths must start with a "/": ' + path) | ||
router.trie.define(path).forEach(function (node) { | ||
@@ -56,3 +53,3 @@ if (!~nodes.indexOf(node)) nodes.push(node) | ||
if (!nodes.length) throw new Error('No routes defined. Something went wrong.') | ||
assert(nodes.length, 'No routes defined. Something went wrong.') | ||
} | ||
@@ -59,0 +56,0 @@ |
{ | ||
"name": "koa-trie-router", | ||
"description": "Trie-routing for Koa", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jonathan Ong", |
8833
147