Comparing version 6.6.1 to 6.6.2
{ | ||
"name": "wayfarer", | ||
"version": "6.6.1", | ||
"version": "6.6.2", | ||
"description": "Composable trie based router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -216,2 +216,34 @@ var wayfarer = require('../') | ||
t.test('wildcards dont conflict with params', function (t) { | ||
t.plan(3) | ||
var router | ||
router = wayfarer() | ||
router.on('/*', function (params) { | ||
t.fail('wildcard called') | ||
}) | ||
router.on('/:match', function (params) { | ||
t.pass('param called') | ||
}) | ||
router('/foo') | ||
router = wayfarer() | ||
router.on('/*', function (params) { | ||
t.fail('wildcard called') | ||
}) | ||
router.on('/:match/foo', function (params) { | ||
t.pass('param called') | ||
}) | ||
router('/foo/foo') | ||
router = wayfarer() | ||
router.on('/*', function (params) { | ||
t.pass('wildcard called') | ||
}) | ||
router.on('/:match/foo', function (params) { | ||
t.fail('param called') | ||
}) | ||
router('/foo/bar') | ||
}) | ||
t.test('safe decodeURIComponent', function (t) { | ||
@@ -218,0 +250,0 @@ t.plan(1) |
16
trie.js
@@ -73,2 +73,10 @@ var mutate = require('xtend/mutable') | ||
return search(index + 1, trie.nodes[thisRoute]) | ||
} else if (trie.name) { | ||
// match named routes | ||
try { | ||
params[trie.name] = decodeURIComponent(thisRoute) | ||
} catch (e) { | ||
return search(index, undefined) | ||
} | ||
return search(index + 1, trie.nodes['$$']) | ||
} else if (trie.wildcard) { | ||
@@ -83,10 +91,2 @@ // match wildcards | ||
return trie.nodes['$$'] | ||
} else if (trie.name) { | ||
// match named routes | ||
try { | ||
params[trie.name] = decodeURIComponent(thisRoute) | ||
} catch (e) { | ||
return search(index, undefined) | ||
} | ||
return search(index + 1, trie.nodes['$$']) | ||
} else { | ||
@@ -93,0 +93,0 @@ // no matches found |
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
28849
630