Comparing version 0.1.1 to 0.1.2
@@ -10,6 +10,6 @@ /** | ||
var pathToRegexp = require('path-to-regexp'); | ||
var reverend = require('reverend'); | ||
var METHODS = { | ||
GET: 'get' | ||
}; | ||
var cachedCompilers = {}; | ||
@@ -138,8 +138,25 @@ /** | ||
Route.prototype.makePath = function (params) { | ||
try { | ||
return reverend(this.config.path, params); | ||
} catch (e) { | ||
debug('Route.makePath failed, e = ', e); | ||
return null; | ||
var routePath = this.config.path; | ||
var compiler; | ||
var err; | ||
if (Array.isArray(routePath)) { | ||
routePath = routePath[0]; | ||
} | ||
if (typeof routePath === 'string') { | ||
compiler = cachedCompilers[routePath] || pathToRegexp.compile(routePath); | ||
cachedCompilers[routePath] = compiler; | ||
try { | ||
return compiler(params); | ||
} catch (e) { | ||
err = e; | ||
} | ||
} else { | ||
err = new TypeError('route path must be a string:' + routePath); | ||
} | ||
debug('Route.makePath failed, e = ', err); | ||
return null; | ||
}; | ||
@@ -243,2 +260,2 @@ | ||
module.exports = Router; | ||
module.exports = Router; |
{ | ||
"name": "routr", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A router for both server and client", | ||
@@ -24,4 +24,3 @@ "main": "index.js", | ||
"debug": "^2.0.0", | ||
"path-to-regexp": "^1.0.0", | ||
"reverend": "^0.3.0" | ||
"path-to-regexp": "^1.1.1" | ||
}, | ||
@@ -28,0 +27,0 @@ "devDependencies": { |
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
17248
2
238
- Removedreverend@^0.3.0
- Removedreverend@0.3.1(transitive)
Updatedpath-to-regexp@^1.1.1