radix-router
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -69,3 +69,2 @@ 'use strict'; | ||
console.log('string',str); | ||
// largest prefix | ||
@@ -132,3 +131,2 @@ return str.slice(0, index); | ||
console.log('prefix', prefix); | ||
// no matches, return null | ||
@@ -217,3 +215,2 @@ if (prefix.length === 0) { | ||
if (str.length === 0 || str === '/') { | ||
console.log('!!!!!!!!!!!!!!!!!!!!!!string length is zero'); | ||
return new Node('/', data); | ||
@@ -223,3 +220,2 @@ } | ||
var sections = str.split('/'); | ||
console.log('sections', sections); | ||
// first section is a special case, if it has real content, create a node | ||
@@ -226,0 +222,0 @@ // otherwise, create an empty node |
@@ -15,3 +15,3 @@ { | ||
"name": "radix-router", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Radix tree based router", | ||
@@ -18,0 +18,0 @@ "main": "index.js", |
@@ -20,10 +20,16 @@ # Radix Router | ||
`insert(path, data)` - adds the given path to the router and associates the given data with the path | ||
`new RadixRouter(options)` - Creates a new instance of a router. The `options` object is optional. | ||
`lookup(path)` - performs a lookup of the path. If there is a match, the data associated with the route is returned | ||
Possible parameters for the `options` object: | ||
`delete(path)` - deletes the path from the router | ||
- `strict` - Setting this option to `true` will force lookups to match exact paths (trailing slashes will not be ignored). Defaults to `false`. | ||
`startsWith(prefix)` - returns a map of all routes starting with the given prefix and the data associated with them | ||
`insert(path, data)` - Adds the given path to the router and associates the given data with the path. | ||
`lookup(path)` - Performs a lookup of the path. If there is a match, the data associated with the route is returned. | ||
`delete(path)` - Deletes the path from the router. | ||
`startsWith(prefix)` - Returns a map of all routes starting with the given prefix and the data associated with them. | ||
### Example | ||
@@ -34,3 +40,5 @@ | ||
let router = new RadixRouter(); | ||
let router = new RadixRouter({ | ||
strict: true | ||
}); | ||
@@ -37,0 +45,0 @@ router.insert('/api/v1/route', { |
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
78765
104
817