radix-router
Advanced tools
Comparing version 2.0.0 to 3.0.0
24
index.js
@@ -16,5 +16,6 @@ 'use strict' | ||
var pathEnd | ||
// allow for trailing slashes to match by removing it | ||
if (!strictPaths && path.length > 1 && path[path.length - 1] === '/') { | ||
path = path.slice(0, path.length - 1) | ||
if (!strictPaths && path.length > 1 && path[(pathEnd = path.length - 1)] === '/') { | ||
path = path.slice(0, pathEnd) | ||
} | ||
@@ -62,5 +63,4 @@ | ||
// optimization: pushing to an array is much faster than setting | ||
// a value in an object, so store params as array | ||
var params = [] | ||
var params = {} | ||
var paramsFound = false | ||
var wildcardNode = null | ||
@@ -83,3 +83,4 @@ var node = rootNode | ||
if (node !== null) { | ||
params.push(section) | ||
params[node.paramName] = section | ||
paramsFound = true | ||
} else { | ||
@@ -97,3 +98,3 @@ break | ||
node: node, | ||
params: params | ||
params: paramsFound ? params : undefined | ||
} | ||
@@ -154,3 +155,3 @@ } | ||
if (data !== null && params.length > 0) { | ||
if (data !== null && params !== undefined) { | ||
data.params = params | ||
@@ -176,2 +177,3 @@ } | ||
var resultArray = [] | ||
var endSections = sections.length - 1 | ||
@@ -189,3 +191,3 @@ for (var i = 0; i < sections.length; i++) { | ||
node = nextNode | ||
} else if (i === sections.length - 1) { | ||
} else if (i === endSections) { | ||
var keys = Object.keys(node.children) | ||
@@ -294,7 +296,7 @@ | ||
if (!node) { | ||
break | ||
return success | ||
} | ||
} | ||
if (node && node.data) { | ||
if (node.data) { | ||
var lastSection = sections[sections.length - 1] | ||
@@ -301,0 +303,0 @@ node.data = null |
{ | ||
"devDependencies": { | ||
"benchmark": "^2.1.2", | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.11.14", | ||
"eslint": "^3.15.0", | ||
"eslint-config-standard": "^6.2.1", | ||
"eslint-plugin-promise": "^3.4.1", | ||
"eslint-plugin-standard": "^2.0.1", | ||
"git-hooks": "^1.1.6", | ||
"istanbul": "^0.4.5", | ||
"jscs": "^3.0.7", | ||
"jshint": "^2.9.4", | ||
"mocha": "^3.1.2", | ||
"path-based-router": "^1.1.3", | ||
"radix-tree": "^0.3.4" | ||
}, | ||
"name": "radix-router", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Radix tree based router", | ||
@@ -29,7 +13,24 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "./run-tests.sh", | ||
"pretest": "eslint .", | ||
"test": "mocha test", | ||
"test-coverage": "istanbul cover _mocha --include-all-sources -- --ui bdd --reporter spec ./tests", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"lint": "eslint ." | ||
}, | ||
"devDependencies": { | ||
"benchmark": "^2.1.4", | ||
"chai": "^4.0.1", | ||
"coveralls": "^2.11.14", | ||
"eslint": "^4.1.0", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-node": "^5.2.0", | ||
"eslint-plugin-promise": "^3.4.1", | ||
"eslint-plugin-standard": "^3.0.1", | ||
"git-hooks": "^1.1.6", | ||
"istanbul": "^0.4.5", | ||
"jscs": "^3.0.7", | ||
"jshint": "^2.9.4", | ||
"mocha": "^3.1.2" | ||
} | ||
} |
# Radix Router | ||
[](https://greenkeeper.io/) | ||
[](https://travis-ci.org/charlieduong94/radix-router) | ||
@@ -174,3 +176,5 @@ [](https://coveralls.io/github/charlieduong94/radix-router?branch=master) | ||
very: 'placeholder', | ||
params: [ 'application' ] | ||
params: { | ||
myPlaceholder: 'application' | ||
} | ||
} | ||
@@ -184,4 +188,7 @@ ``` | ||
very: 'placeholder', | ||
params: [ 'test-org', 'test-group-id' ] | ||
params: { | ||
organizations: 'test-org', | ||
groupId: 'test-group-id' | ||
} | ||
} | ||
``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
611
193
25198
13