Comparing version 2.1.1 to 2.2.0
@@ -44,3 +44,3 @@ | ||
return match.node.cb(match ? match.param : {}) | ||
return match.node.cb(path, match ? match.param : {}) | ||
} | ||
@@ -47,0 +47,0 @@ |
{ | ||
"name": "wayfarer", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "A simple router built for minimalism and speed", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "NODE_ENV=test ./node_modules/mocha/bin/mocha --recursive --harmony-generators -R spec", | ||
"coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report text --recursive -- -R spec && rm -rf ./coverage/" | ||
"test": "NODE_ENV=test tape test.js | tap-bail | tap-spec", | ||
"test-cov": "NODE_ENV=test istanbul cover test.js" | ||
}, | ||
@@ -33,4 +33,7 @@ "repository": { | ||
"mocha": "^1.20.1", | ||
"should": "^4.0.4" | ||
"should": "^4.0.4", | ||
"tap-bail": "0.0.0", | ||
"tap-spec": "^2.1.2", | ||
"tape": "^3.0.3" | ||
} | ||
} |
@@ -26,3 +26,3 @@ # wayfarer | ||
router.match('/tobi') | ||
// => '/:user' | ||
// => '/user' | ||
``` | ||
@@ -50,5 +50,18 @@ | ||
```js | ||
router.on('/:user', (param) => console.log('do user stuff', param.user)) | ||
router.on('/:user', (uri, param) => console.log('my name is ', param.user)) | ||
``` | ||
Nested routers are supported by passing in `.match()` as the callback to | ||
another router. | ||
```js | ||
const main = wayfarer() | ||
const sub = wayfarer() | ||
main.on('/foo', sub.match.bind(sub)) | ||
sub.on('/foo/bar'), (uri) => console.log(uri)) | ||
main.match('/foo/bar') | ||
// '/foo/bar' | ||
``` | ||
#### .match(path) | ||
@@ -64,2 +77,3 @@ Match a path against the saved paths in the router. If a match is | ||
- [hash-match](https://github.com/sethvincent/hash-match) - easy `window.location.hash` matching | ||
- [pathname-match](https://github.com/yoshuawuyts/pathname-match) - strip a url to only match the pathname | ||
@@ -66,0 +80,0 @@ ## License |
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
6687
88
7