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

overalls

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

overalls - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

8

examples/simple.js

@@ -5,3 +5,3 @@ var http = require("http");

//parameters are between {curlybraces}
var routes = ["GET /", "GET /dogs/{dog}", "GET /cats/{cat}", "GET /boing"];
var routes = ["GET /", "GET /dogs/{dog}", "GET /cats/{cat}", "GET /boing", "GET /n/{n}/m/{m}"];

@@ -17,3 +17,2 @@ //overalls is configured with an array or object with paths

res.writeHead(200, {"Content-Type": "text/plain"});
if(req.params) {

@@ -25,3 +24,6 @@

res.write("cat: " + req.params.cat);
}
} else if (req.params.n || req.params.m) {
res.write("n: " + req.params.n + " m: " + req.params.m);
console.log(req.params);
};

@@ -28,0 +30,0 @@ } else {

@@ -58,26 +58,29 @@ function splitPath (path) {

if (req.hasOwnProperty("params")) {
if (req.hasOwnProperty("params")) {
return;
}
var i, match, il = requestSegments.length;
}
if(requestSegments.length !== routeSegments.length) {
return;
}
for (i = 0; i < il; i += 1) {
match = compareSegments(routeSegments[i], requestSegments[i]);
var i, match, il = requestSegments.length;
if (typeof match === "object") {
req.params = {};
req.params[match.key] = match.value;
} else if (!match) {
delete req.params
return;
}
if(requestSegments.length !== routeSegments.length) {
return;
}
if ((i === (il-1)) && match) {
req.match = routeSegments.join("/");
}
for (i = 0; i < il; i += 1) {
match = compareSegments(routeSegments[i], requestSegments[i]);
if (typeof match === "object") {
req.params = req.params || {};
req.params[match.key] = match.value;
} else if (!match) {
delete req.params
return;
}
if ((i === (il-1)) && match) {
req.match = routeSegments.join("/");
}
}
});

@@ -84,0 +87,0 @@ };

{
"name": "overalls",
"version": "1.0.2",
"version": "1.0.3",
"description": "Decorate HTTP requests with path parameters",

@@ -5,0 +5,0 @@ "main": "index.js",

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