route-node
Advanced tools
Comparing version 1.8.5 to 1.9.0
@@ -0,1 +1,11 @@ | ||
<a name="1.9.0"></a> | ||
# [1.9.0](https://github.com/troch/route-node/compare/v1.8.5...v1.9.0) (2017-10-05) | ||
### Features | ||
* treat repeating slashes as pathless paths ([#13](https://github.com/troch/route-node/issues/13)) ([4a8a41f](https://github.com/troch/route-node/commit/4a8a41f)) | ||
<a name="1.8.5"></a> | ||
@@ -2,0 +12,0 @@ ## [1.8.5](https://github.com/troch/route-node/compare/v1.8.4...v1.8.5) (2017-08-10) |
@@ -764,3 +764,3 @@ define('RouteNode', function () { 'use strict'; | ||
var matchChildren = function matchChildren(nodes, pathSegment, segments) { | ||
var matchChildren = function matchChildren(nodes, pathSegment, segments, consumedBefore) { | ||
var isRoot = nodes.length === 1 && nodes[0].name === ''; | ||
@@ -775,9 +775,16 @@ // for (child of node.children) { | ||
var remainingPath = void 0; | ||
var segment = pathSegment; | ||
if (consumedBefore === '/' && child.path === '/') { | ||
// when we encounter repeating slashes we add the slash | ||
// back to the URL to make it de facto pathless | ||
segment = '/' + pathSegment; | ||
} | ||
if (!child.children.length) { | ||
match = child.parser.test(pathSegment, { trailingSlash: trailingSlash }); | ||
match = child.parser.test(segment, { trailingSlash: trailingSlash }); | ||
} | ||
if (!match) { | ||
match = child.parser.partialTest(pathSegment, { delimiter: strongMatching }); | ||
match = child.parser.partialTest(segment, { delimiter: strongMatching }); | ||
} | ||
@@ -792,3 +799,3 @@ | ||
remainingPath = pathSegment.replace(consumedPath, ''); | ||
remainingPath = segment.replace(consumedPath, ''); | ||
@@ -799,3 +806,3 @@ if (trailingSlash && !child.children.length) { | ||
var search = omit(getSearch(pathSegment.replace(consumedPath, '')), child.parser.queryParams.concat(child.parser.queryParamsBr)); | ||
var search = omit(getSearch(segment.replace(consumedPath, '')), child.parser.queryParams.concat(child.parser.queryParamsBr)); | ||
remainingPath = getPath(remainingPath) + (search ? '?' + search : ''); | ||
@@ -840,3 +847,3 @@ if (trailingSlash && !isRoot && remainingPath === '/' && !/\/$/.test(consumedPath)) { | ||
return { | ||
v: matchChildren(children, remainingPath, segments) | ||
v: matchChildren(children, remainingPath, segments, consumedPath) | ||
}; | ||
@@ -928,3 +935,5 @@ } | ||
return segment.absolute ? segmentPath : path + segmentPath; | ||
}, ''); | ||
}, '') | ||
// remove repeated slashes | ||
.replace(/\/\/{1,}/g, '/'); | ||
@@ -931,0 +940,0 @@ var finalPath = path; |
@@ -249,3 +249,3 @@ 'use strict'; | ||
var matchChildren = function matchChildren(nodes, pathSegment, segments) { | ||
var matchChildren = function matchChildren(nodes, pathSegment, segments, consumedBefore) { | ||
var isRoot = nodes.length === 1 && nodes[0].name === ''; | ||
@@ -260,9 +260,16 @@ // for (child of node.children) { | ||
var remainingPath = void 0; | ||
var segment = pathSegment; | ||
if (consumedBefore === '/' && child.path === '/') { | ||
// when we encounter repeating slashes we add the slash | ||
// back to the URL to make it de facto pathless | ||
segment = '/' + pathSegment; | ||
} | ||
if (!child.children.length) { | ||
match = child.parser.test(pathSegment, { trailingSlash: trailingSlash }); | ||
match = child.parser.test(segment, { trailingSlash: trailingSlash }); | ||
} | ||
if (!match) { | ||
match = child.parser.partialTest(pathSegment, { delimiter: strongMatching }); | ||
match = child.parser.partialTest(segment, { delimiter: strongMatching }); | ||
} | ||
@@ -277,3 +284,3 @@ | ||
remainingPath = pathSegment.replace(consumedPath, ''); | ||
remainingPath = segment.replace(consumedPath, ''); | ||
@@ -284,3 +291,3 @@ if (trailingSlash && !child.children.length) { | ||
var search = (0, _searchParams.omit)((0, _searchParams.getSearch)(pathSegment.replace(consumedPath, '')), child.parser.queryParams.concat(child.parser.queryParamsBr)); | ||
var search = (0, _searchParams.omit)((0, _searchParams.getSearch)(segment.replace(consumedPath, '')), child.parser.queryParams.concat(child.parser.queryParamsBr)); | ||
remainingPath = (0, _searchParams.getPath)(remainingPath) + (search ? '?' + search : ''); | ||
@@ -325,3 +332,3 @@ if (trailingSlash && !isRoot && remainingPath === '/' && !/\/$/.test(consumedPath)) { | ||
return { | ||
v: matchChildren(children, remainingPath, segments) | ||
v: matchChildren(children, remainingPath, segments, consumedPath) | ||
}; | ||
@@ -413,3 +420,5 @@ } | ||
return segment.absolute ? segmentPath : path + segmentPath; | ||
}, ''); | ||
}, '') | ||
// remove repeated slashes | ||
.replace(/\/\/{1,}/g, '/'); | ||
@@ -416,0 +425,0 @@ var finalPath = path; |
@@ -768,3 +768,3 @@ (function (global, factory) { | ||
var matchChildren = function matchChildren(nodes, pathSegment, segments) { | ||
var matchChildren = function matchChildren(nodes, pathSegment, segments, consumedBefore) { | ||
var isRoot = nodes.length === 1 && nodes[0].name === ''; | ||
@@ -779,9 +779,16 @@ // for (child of node.children) { | ||
var remainingPath = void 0; | ||
var segment = pathSegment; | ||
if (consumedBefore === '/' && child.path === '/') { | ||
// when we encounter repeating slashes we add the slash | ||
// back to the URL to make it de facto pathless | ||
segment = '/' + pathSegment; | ||
} | ||
if (!child.children.length) { | ||
match = child.parser.test(pathSegment, { trailingSlash: trailingSlash }); | ||
match = child.parser.test(segment, { trailingSlash: trailingSlash }); | ||
} | ||
if (!match) { | ||
match = child.parser.partialTest(pathSegment, { delimiter: strongMatching }); | ||
match = child.parser.partialTest(segment, { delimiter: strongMatching }); | ||
} | ||
@@ -796,3 +803,3 @@ | ||
remainingPath = pathSegment.replace(consumedPath, ''); | ||
remainingPath = segment.replace(consumedPath, ''); | ||
@@ -803,3 +810,3 @@ if (trailingSlash && !child.children.length) { | ||
var search = omit(getSearch(pathSegment.replace(consumedPath, '')), child.parser.queryParams.concat(child.parser.queryParamsBr)); | ||
var search = omit(getSearch(segment.replace(consumedPath, '')), child.parser.queryParams.concat(child.parser.queryParamsBr)); | ||
remainingPath = getPath(remainingPath) + (search ? '?' + search : ''); | ||
@@ -844,3 +851,3 @@ if (trailingSlash && !isRoot && remainingPath === '/' && !/\/$/.test(consumedPath)) { | ||
return { | ||
v: matchChildren(children, remainingPath, segments) | ||
v: matchChildren(children, remainingPath, segments, consumedPath) | ||
}; | ||
@@ -932,3 +939,5 @@ } | ||
return segment.absolute ? segmentPath : path + segmentPath; | ||
}, ''); | ||
}, '') | ||
// remove repeated slashes | ||
.replace(/\/\/{1,}/g, '/'); | ||
@@ -935,0 +944,0 @@ var finalPath = path; |
@@ -189,3 +189,3 @@ import Path from 'path-parser'; | ||
const { trailingSlash, strictQueryParams, strongMatching } = options; | ||
let matchChildren = (nodes, pathSegment, segments) => { | ||
let matchChildren = (nodes, pathSegment, segments, consumedBefore) => { | ||
const isRoot = nodes.length === 1 && nodes[0].name === ''; | ||
@@ -195,2 +195,3 @@ // for (child of node.children) { | ||
const child = nodes[i]; | ||
@@ -200,9 +201,16 @@ // Partially match path | ||
let remainingPath; | ||
let segment = pathSegment; | ||
if (consumedBefore === '/' && child.path === '/') { | ||
// when we encounter repeating slashes we add the slash | ||
// back to the URL to make it de facto pathless | ||
segment = '/' + pathSegment; | ||
} | ||
if (!child.children.length) { | ||
match = child.parser.test(pathSegment, { trailingSlash }); | ||
match = child.parser.test(segment, { trailingSlash }); | ||
} | ||
if (!match) { | ||
match = child.parser.partialTest(pathSegment, { delimiter: strongMatching }); | ||
match = child.parser.partialTest(segment, { delimiter: strongMatching }); | ||
} | ||
@@ -217,10 +225,10 @@ | ||
remainingPath = pathSegment.replace(consumedPath, ''); | ||
remainingPath = segment.replace(consumedPath, ''); | ||
if (trailingSlash && !child.children.length) { | ||
remainingPath = remainingPath.replace(/^\/\?/, '?'); | ||
} | ||
const search = omit( | ||
getSearch(pathSegment.replace(consumedPath, '')), | ||
getSearch(segment.replace(consumedPath, '')), | ||
child.parser.queryParams.concat(child.parser.queryParamsBr) | ||
@@ -252,3 +260,3 @@ ); | ||
// Else: remaining path and children | ||
return matchChildren(children, remainingPath, segments); | ||
return matchChildren(children, remainingPath, segments, consumedPath); | ||
} | ||
@@ -334,3 +342,5 @@ } | ||
return segment.absolute ? segmentPath : path + segmentPath; | ||
}, ''); | ||
}, '') | ||
// remove repeated slashes | ||
.replace(/\/\/{1,}/g, '/'); | ||
@@ -337,0 +347,0 @@ let finalPath = path; |
{ | ||
"name": "route-node", | ||
"version": "1.8.5", | ||
"version": "1.9.0", | ||
"description": "A package to create a tree of named routes", | ||
@@ -5,0 +5,0 @@ "main": "dist/commonjs/route-node.js", |
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
248394
2501