Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

routr

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

routr - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

31

lib/router.js

@@ -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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc