Comparing version 4.2.0 to 4.3.0
24
index.js
@@ -38,3 +38,3 @@ const routington = require('routington') | ||
// str -> null | ||
function emit (path, params) { | ||
function emit (path, params, parentDefault) { | ||
path = sanitizeUri(path) || '' | ||
@@ -46,3 +46,4 @@ params = params || {} | ||
const match = sub ? sub.match : router.match(path) || router.match(dft) | ||
const localDft = router.match(dft) || parentDefault | ||
const match = sub ? sub.match : router.match(path) || localDft | ||
assert.ok(match, 'path ' + path + ' did not match') | ||
@@ -53,3 +54,3 @@ params = xtend(params, match.param) | ||
match.node.cb.forEach(function (cb) { | ||
sub ? cb(path, params) : cb(params) | ||
sub ? cb(path, params, localDft) : cb(params) | ||
}) | ||
@@ -76,4 +77,7 @@ } | ||
var nw = '' | ||
while (++cnt < ln) nw = nw ? nw.concat('/', split[cnt]) : split[cnt] | ||
while (++cnt < ln) { | ||
nw = nw ? nw.concat('/', split[cnt]) : split[cnt] | ||
} | ||
var imatch = mounts.match(nw) | ||
@@ -89,5 +93,13 @@ if (imatch) { | ||
if (!match) return | ||
while (count--) split.shift() | ||
while (count--) { | ||
split.shift() | ||
} | ||
path = split.join('/') | ||
return { match: match, path: path } | ||
const ret = { | ||
match: match, | ||
path: path | ||
} | ||
return ret | ||
} | ||
@@ -94,0 +106,0 @@ } |
{ | ||
"name": "wayfarer", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "Composable trie based router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,3 +36,4 @@ # wayfarer | ||
Routers can be infinitely nested, allowing routing to be scoped per view. | ||
Matched params are passed into subrouters. | ||
Matched params are passed into subrouters. Nested routes will call their | ||
parent's default handler if no path matches. | ||
```js | ||
@@ -39,0 +40,0 @@ const r1 = wayfarer() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7375
89
90