route-node
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -0,1 +1,11 @@ | ||
<a name="1.4.2"></a> | ||
## [1.4.2](https://github.com/troch/route-node/compare/v1.4.1...v1.4.2) (2016-07-20) | ||
### Bug Fixes | ||
* pass route registration callback when adding children routes ([5f58852](https://github.com/troch/route-node/commit/5f58852)) | ||
<a name="1.4.1"></a> | ||
@@ -2,0 +12,0 @@ ## [1.4.1](https://github.com/troch/route-node/compare/v1.4.0...v1.4.1) (2016-03-29) |
@@ -114,3 +114,3 @@ define('RouteNode', function () { 'use strict'; | ||
var defaultOrConstrained = function defaultOrConstrained(match) { | ||
return '(' + (match ? match.replace(/(^<|>$)/g, '') : '[a-zA-Z0-9-_.~]+') + ')'; | ||
return '(' + (match ? match.replace(/(^<|>$)/g, '') : '[a-zA-Z0-9-_.~%]+') + ')'; | ||
}; | ||
@@ -235,3 +235,3 @@ | ||
var toSerialisable = function toSerialisable(val) { | ||
return val !== undefined && val !== null && val !== '' ? '=' + encodeURIComponent(val) : ''; | ||
return val !== undefined && val !== null && val !== '' ? '=' + val : ''; | ||
}; | ||
@@ -329,3 +329,3 @@ | ||
return match.slice(1, this.urlParams.length + 1).reduce(function (params, m, i) { | ||
params[_this.urlParams[i]] = m; | ||
params[_this.urlParams[i]] = decodeURIComponent(m); | ||
return params; | ||
@@ -396,2 +396,11 @@ }, {}); | ||
var encodedParams = Object.keys(params).reduce(function (acc, key) { | ||
// Use encodeURI in case of spats | ||
if (params[key] === undefined) { | ||
acc[key] = undefined; | ||
} else { | ||
acc[key] = Array.isArray(params[key]) ? params[key].map(encodeURI) : encodeURI(params[key]); | ||
} | ||
return acc; | ||
}, {}); | ||
// Check all params are provided (not search parameters which are optional) | ||
@@ -408,3 +417,3 @@ if (this.urlParams.some(function (p) { | ||
}).every(function (t) { | ||
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(params[t.val]); | ||
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(encodedParams[t.val]); | ||
}); | ||
@@ -419,4 +428,4 @@ | ||
}).map(function (t) { | ||
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + params[t.val[0]]; | ||
return (/^url-parameter/.test(t.type) ? params[t.val[0]] : t.match | ||
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + encodedParams[t.val[0]]; | ||
return (/^url-parameter/.test(t.type) ? encodedParams[t.val[0]] : t.match | ||
); | ||
@@ -432,5 +441,5 @@ }).join(''); | ||
var searchPart = queryParams.filter(function (p) { | ||
return Object.keys(params).indexOf(withoutBrackets(p)) !== -1; | ||
return Object.keys(encodedParams).indexOf(withoutBrackets(p)) !== -1; | ||
}).map(function (p) { | ||
return _serialise(p, params[withoutBrackets(p)]); | ||
return _serialise(p, encodedParams[withoutBrackets(p)]); | ||
}).join('&'); | ||
@@ -497,3 +506,3 @@ | ||
originalRoute = route; | ||
route = new RouteNode(route.name, route.path, route.children); | ||
route = new RouteNode(route.name, route.path, route.children, cb); | ||
} | ||
@@ -500,0 +509,0 @@ |
@@ -5,4 +5,6 @@ 'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -20,4 +22,2 @@ value: true | ||
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -27,3 +27,3 @@ | ||
var RouteNode = (function () { | ||
var RouteNode = function () { | ||
function RouteNode() { | ||
@@ -62,3 +62,3 @@ var name = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; | ||
var originalRoute = undefined; | ||
var originalRoute = void 0; | ||
if (route === undefined || route === null) return; | ||
@@ -81,3 +81,3 @@ | ||
originalRoute = route; | ||
route = new RouteNode(route.name, route.path, route.children); | ||
route = new RouteNode(route.name, route.path, route.children, cb); | ||
} | ||
@@ -187,3 +187,3 @@ | ||
var match = child.parser.partialMatch(pathSegment); | ||
var remainingPath = undefined; | ||
var remainingPath = void 0; | ||
@@ -358,5 +358,5 @@ if (!match && trailingSlash) { | ||
return RouteNode; | ||
})(); | ||
}(); | ||
exports.default = RouteNode; | ||
module.exports = exports['default']; |
@@ -118,3 +118,3 @@ (function (global, factory) { | ||
var defaultOrConstrained = function defaultOrConstrained(match) { | ||
return '(' + (match ? match.replace(/(^<|>$)/g, '') : '[a-zA-Z0-9-_.~]+') + ')'; | ||
return '(' + (match ? match.replace(/(^<|>$)/g, '') : '[a-zA-Z0-9-_.~%]+') + ')'; | ||
}; | ||
@@ -239,3 +239,3 @@ | ||
var toSerialisable = function toSerialisable(val) { | ||
return val !== undefined && val !== null && val !== '' ? '=' + encodeURIComponent(val) : ''; | ||
return val !== undefined && val !== null && val !== '' ? '=' + val : ''; | ||
}; | ||
@@ -333,3 +333,3 @@ | ||
return match.slice(1, this.urlParams.length + 1).reduce(function (params, m, i) { | ||
params[_this.urlParams[i]] = m; | ||
params[_this.urlParams[i]] = decodeURIComponent(m); | ||
return params; | ||
@@ -400,2 +400,11 @@ }, {}); | ||
var encodedParams = Object.keys(params).reduce(function (acc, key) { | ||
// Use encodeURI in case of spats | ||
if (params[key] === undefined) { | ||
acc[key] = undefined; | ||
} else { | ||
acc[key] = Array.isArray(params[key]) ? params[key].map(encodeURI) : encodeURI(params[key]); | ||
} | ||
return acc; | ||
}, {}); | ||
// Check all params are provided (not search parameters which are optional) | ||
@@ -412,3 +421,3 @@ if (this.urlParams.some(function (p) { | ||
}).every(function (t) { | ||
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(params[t.val]); | ||
return new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(encodedParams[t.val]); | ||
}); | ||
@@ -423,4 +432,4 @@ | ||
}).map(function (t) { | ||
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + params[t.val[0]]; | ||
return (/^url-parameter/.test(t.type) ? params[t.val[0]] : t.match | ||
if (t.type === 'url-parameter-matrix') return ';' + t.val + '=' + encodedParams[t.val[0]]; | ||
return (/^url-parameter/.test(t.type) ? encodedParams[t.val[0]] : t.match | ||
); | ||
@@ -436,5 +445,5 @@ }).join(''); | ||
var searchPart = queryParams.filter(function (p) { | ||
return Object.keys(params).indexOf(withoutBrackets(p)) !== -1; | ||
return Object.keys(encodedParams).indexOf(withoutBrackets(p)) !== -1; | ||
}).map(function (p) { | ||
return _serialise(p, params[withoutBrackets(p)]); | ||
return _serialise(p, encodedParams[withoutBrackets(p)]); | ||
}).join('&'); | ||
@@ -501,3 +510,3 @@ | ||
originalRoute = route; | ||
route = new RouteNode(route.name, route.path, route.children); | ||
route = new RouteNode(route.name, route.path, route.children, cb); | ||
} | ||
@@ -504,0 +513,0 @@ |
@@ -40,3 +40,3 @@ import Path from 'path-parser'; | ||
originalRoute = route; | ||
route = new RouteNode(route.name, route.path, route.children); | ||
route = new RouteNode(route.name, route.path, route.children, cb); | ||
} | ||
@@ -43,0 +43,0 @@ |
{ | ||
"name": "route-node", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "A package to create a tree of named routes", | ||
@@ -57,5 +57,5 @@ "main": "dist/commonjs/route-node.js", | ||
"dependencies": { | ||
"path-parser": "~1.0.2", | ||
"path-parser": "~1.0.4", | ||
"search-params": "~1.2.0" | ||
} | ||
} |
@@ -10,3 +10,2 @@ [![npm version](https://badge.fury.io/js/route-node.svg)](http://badge.fury.io/js/route-node) | ||
**This module is being used for developing a router, API is subject to change without notice** | ||
@@ -13,0 +12,0 @@ ## Install |
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
216996
2300
90
Updatedpath-parser@~1.0.4