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

router

Package Overview
Dependencies
Maintainers
0
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

router - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

example.js

27

index.js

@@ -131,18 +131,29 @@ var common = require('common');

var url = path.normalize(request.url.split('?')[0]);
var onnotfound = function() {
response.writeHead(404);
response.end();
};
if (/\/\.\.\//.test(url)) { // security check
response.writeHead(404);
response.end();
onnotfound();
return;
}
fs.stat(url, common.fork(onnotfound, function(stat) {
var ifmod = request.headers['if-modified-since'];
fs.readFile(url, function(err, buffer) {
if (err) {
response.writeHead(404);
if (ifmod && new Date(ifmod) >= stat.mtime) {
response.writeHead(304);
response.end();
return;
}
response.writeHead(options.status, {'content-type':mimes.resolve(url)});
response.end(buffer);
});
response.writeHead(options.status, {
'content-type':mimes.resolve(url),
'content-length':stat.size,
'date':new Date().toUTCString(),
'last-modified':stat.mtime.toUTCString()
});
fs.createReadStream(url).pipe(response);
}));
});

@@ -149,0 +160,0 @@ };

{
"name":"router",
"version":"0.3.0",
"version":"0.3.1",
"description":"A lean and mean web router",

@@ -5,0 +5,0 @@ "contributors": [

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